diff --git a/thunar-volman/tvm-block-device.c b/thunar-volman/tvm-block-device.c index edb6cad..07b5150 100644 --- a/thunar-volman/tvm-block-device.c +++ b/thunar-volman/tvm-block-device.c @@ -709,19 +709,12 @@ tvm_block_device_mount_finish (GVolume *volume, static gboolean -tvm_block_device_mount (TvmContext *context) +tvm_block_device_mount_volume (TvmContext *context, GVolume *volume) { GMountOperation *mount_operation; - GVolume *volume; g_return_val_if_fail ((context != NULL), FALSE); - /* determine the GVolume corresponding to the udev device */ - volume = - tvm_g_volume_monitor_get_volume_for_kind (context->monitor, - G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE, - g_udev_device_get_device_file (context->device)); - /* check if we have a volume */ if (volume != NULL) { @@ -754,7 +747,48 @@ tvm_block_device_mount (TvmContext *context) return FALSE; } +static gboolean +tvm_block_device_mount_retry (TvmContext *context) +{ + GVolume *volume; + + g_return_val_if_fail ((context != NULL), FALSE); + + volume = + tvm_g_volume_monitor_get_volume_for_kind (context->monitor, + G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE, + g_udev_device_get_device_file (context->device)); + + /* if no volume then call anyway to do not-found processing */ + tvm_block_device_mount_volume (context,volume); + return FALSE; +} + +static gboolean +tvm_block_device_mount (TvmContext *context) +{ + GVolume *volume; + + g_return_if_fail (context != NULL); + /* determine the GVolume corresponding to the udev device */ + volume = + tvm_g_volume_monitor_get_volume_for_kind (context->monitor, + G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE, + g_udev_device_get_device_file (context->device)); + if (volume != NULL) + { + tvm_block_device_mount_volume(context,volume); + } + else + { + /* clean up and try again in one second */ + g_object_unref (context->monitor); + context->monitor = g_volume_monitor_get (); + g_timeout_add_seconds(1, (GSourceFunc) tvm_block_device_mount_retry, context); + } + return FALSE; +} void tvm_block_device_added (TvmContext *context) @@ -882,7 +916,7 @@ automount_disc: if (automount) { /* mount the CD/DVD and continue with inspecting its contents */ - g_timeout_add_seconds(5, (GSourceFunc) tvm_block_device_mount, context); + tvm_block_device_mount(context); } } else @@ -905,7 +939,7 @@ automount_disc: if (automount) { /* mount the partition and continue with inspecting its contents */ - g_timeout_add_seconds(5, (GSourceFunc) tvm_block_device_mount, context); + tvm_block_device_mount(context); } else {