diff options
author | Philip Langdale <philipl@overt.org> | 2014-07-26 21:04:53 -0700 |
---|---|---|
committer | Philip Langdale <philipl@overt.org> | 2014-07-26 21:04:53 -0700 |
commit | be000ea91e90186bb6f1031348e33d5b9025251a (patch) | |
tree | 27cd0a3844dd041d8109d6aeaf3b44deefb56e3f /daemon | |
parent | f92fbc0f481f41c04fd61fa4c061c418cc3a0c8c (diff) | |
download | gvfs-be000ea91e90186bb6f1031348e33d5b9025251a.tar.gz |
MTP: Emit delete events when unmounting.
Although it would seem obvious that a mount disappearing should
invalidate any file references in clients, recent versions of
Nautilus will keep open windows around, showing all the files that
were there at the time of the unmount.
So, clearly we need to emit these events to get it to clean itself
up.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gvfsbackendmtp.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c index bbd2433d..ee503503 100644 --- a/daemon/gvfsbackendmtp.c +++ b/daemon/gvfsbackendmtp.c @@ -586,6 +586,20 @@ on_uevent (GUdevClient *client, gchar *action, GUdevDevice *device, gpointer use if (g_strcmp0 (op_backend->dev_path, dev_path) == 0 && g_str_equal (action, "remove")) { DEBUG ("(I) on_uevent: Quiting after remove event on device %s\n", dev_path); + + /* Emit delete events to tell clients files are gone. */ + GHashTableIter iter; + gpointer key, value; + g_hash_table_iter_init (&iter, op_backend->file_cache); + while (g_hash_table_iter_next (&iter, &key, &value)) { + const char *path = key; + const CacheEntry *entry = value; + + g_hash_table_foreach (op_backend->monitors, + emit_delete_event, + (char *)path); + } + g_vfs_backend_force_unmount ((GVfsBackend*)op_backend); } @@ -840,6 +854,18 @@ do_unmount (GVfsBackend *backend, GVfsJobUnmount *job, g_atomic_int_set (&op_backend->unmount_started, TRUE); + /* Emit delete events to tell clients files are gone. */ + GHashTableIter iter; + gpointer key, value; + g_hash_table_iter_init (&iter, op_backend->file_cache); + while (g_hash_table_iter_next (&iter, &key, &value)) { + const char *path = key; + const CacheEntry *entry = value; + + g_hash_table_foreach (op_backend->monitors, + emit_delete_event, + (char *)path); + } g_hash_table_unref (op_backend->file_cache); g_source_remove (op_backend->hb_id); |