[rhythmbox] removable-media-manager: monitor mount roots to work around gvfs bug



commit 6bf8364bf3e1fe3f9daaea31b20c8e5ccb928717
Author: Jonathan Matthew <jonathan d14n org>
Date:   Wed Dec 26 17:03:08 2018 +1000

    removable-media-manager: monitor mount roots to work around gvfs bug
    
    gvfs currently does not invalidate its mount info cache when a mount
    is removed unless it has a connection open to the mount process, so
    when another mount appears at the same path, it uses stale
    information to talk to the mount process, so all operations fail.
    
    We can work around this by monitoring the root of the mount, which
    causes gvfs to keep a connection open.

 shell/rb-removable-media-manager.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/shell/rb-removable-media-manager.c b/shell/rb-removable-media-manager.c
index 1791f3a27..b2f02d27f 100644
--- a/shell/rb-removable-media-manager.c
+++ b/shell/rb-removable-media-manager.c
@@ -700,21 +700,26 @@ rb_removable_media_manager_add_mount (RBRemovableMediaManager *mgr, GMount *moun
                return;
        }
        mountpoint = g_file_get_path (mount_root);
-       g_object_unref (mount_root);
 
        device_info = mpid_device_new (mountpoint);
-       g_free (mountpoint);
 
        g_signal_emit (G_OBJECT (mgr), rb_removable_media_manager_signals[CREATE_SOURCE_MOUNT], 0, mount, 
device_info, &source);
 
        if (source) {
+               GFileMonitor *monitor;
+
                g_hash_table_insert (priv->mount_mapping, mount, source);
                rb_removable_media_manager_append_media_source (mgr, source);
+
+               monitor = g_file_monitor_directory (mount_root, G_FILE_MONITOR_NONE, NULL, NULL);
+               g_object_set_data (G_OBJECT (mount), "rb-file-monitor", monitor);
        } else {
                rb_debug ("Unhandled media");
        }
 
        g_object_unref (device_info);
+       g_free (mountpoint);
+       g_object_unref (mount_root);
 }
 
 static void
@@ -722,6 +727,7 @@ rb_removable_media_manager_remove_mount (RBRemovableMediaManager *mgr, GMount *m
 {
        RBRemovableMediaManagerPrivate *priv = GET_PRIVATE (mgr);
        RBSource *source;
+       GFileMonitor *monitor;
 
        g_assert (mount != NULL);
 
@@ -730,6 +736,12 @@ rb_removable_media_manager_remove_mount (RBRemovableMediaManager *mgr, GMount *m
        if (source) {
                rb_display_page_delete_thyself (RB_DISPLAY_PAGE (source));
        }
+
+       monitor = G_FILE_MONITOR (g_object_get_data (G_OBJECT (mount), "rb-file-monitor"));
+       if (monitor != NULL) {
+               g_object_unref (monitor);
+               g_object_set_data (G_OBJECT (mount), "rb-file-monitor", NULL);
+       }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]