diff options
author | lukefromdc <[email protected]> | 2018-10-15 22:20:03 -0400 |
---|---|---|
committer | lukefromdc <[email protected]> | 2018-10-20 14:57:08 -0400 |
commit | 8fff655552209fd181f9608d02d0f72660b10768 (patch) | |
tree | e7cfe7fd6aaa2b31ee4d80095fd7376f3276ea88 /libcaja-private/caja-file-utilities.c | |
parent | 09146ca4fc0c504e75f39be16eefb29ddec5a8e9 (diff) | |
download | caja-8fff655552209fd181f9608d02d0f72660b10768.tar.bz2 caja-8fff655552209fd181f9608d02d0f72660b10768.tar.xz |
monitor: watch for removal of non-native mounts on GVolumeMonitor
Fix https://github.com/mate-desktop/caja/issues/1066 "Caja caches folders from usb drives/disk"
Nowadays, we rely on G_FILE_MONITOR_EVENT_UNMOUNTED to be emitted when a
mount disappears, since we already monitor the directory, in order to
switch the view to a different location.
Since non-native mounts very likely won't have file monitoring though,
we're not going to receive such events in that case, and fail to
redirect the view as a consequence.
This patch fixes it by listening to the mount-removed signal on
GVolumeMonitor when a monitor is requested for a non-native mount, and
emulating a file removal in that case.
Backport Nautilus commit gitlab.gnome.org/GNOME/nautilus/commit/3891241ba760c59d284b7579dbd340651c8d4d29
note that caja_get_mounted_mount_for_root had to be added, while the equivalent Nautilus function was from a prior commit
Diffstat (limited to 'libcaja-private/caja-file-utilities.c')
-rw-r--r-- | libcaja-private/caja-file-utilities.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libcaja-private/caja-file-utilities.c b/libcaja-private/caja-file-utilities.c index 237f85d7..46f90b0a 100644 --- a/libcaja-private/caja-file-utilities.c +++ b/libcaja-private/caja-file-utilities.c @@ -756,6 +756,48 @@ caja_is_desktop_directory (GFile *dir) return g_file_equal (dir, desktop_dir); } +GMount * +caja_get_mounted_mount_for_root (GFile *location) +{ + GVolumeMonitor *volume_monitor; + GList *mounts; + GList *l; + GMount *mount; + GMount *result = NULL; + GFile *root = NULL; + GFile *default_location = NULL; + + volume_monitor = g_volume_monitor_get (); + mounts = g_volume_monitor_get_mounts (volume_monitor); + + for (l = mounts; l != NULL; l = l->next) { + mount = l->data; + + if (g_mount_is_shadowed (mount)) { + continue; + } + + root = g_mount_get_root (mount); + if (g_file_equal (location, root)) { + result = g_object_ref (mount); + break; + } + + default_location = g_mount_get_default_location (mount); + if (!g_file_equal (default_location, root) && + g_file_equal (location, default_location)) { + result = g_object_ref (mount); + break; + } + } + + g_clear_object (&root); + g_clear_object (&default_location); + g_list_free_full (mounts, g_object_unref); + + return result; +} + /** * caja_get_pixmap_directory * |