summaryrefslogtreecommitdiff
path: root/gio
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-07-30 15:26:31 +0200
committerOndrej Holy <oholy@redhat.com>2018-07-30 16:05:41 +0200
commit9b6b282e0a9d3f37865aa36e21ea57bd2a326e20 (patch)
treef7b2ff01766b4aedfeddffc4793b4cdd9cf53226 /gio
parente5f87342e8f5eaf18d0a1c64ed8e1bfcfe48229b (diff)
downloadglib-9b6b282e0a9d3f37865aa36e21ea57bd2a326e20.tar.gz
gio: Update mounts after g_volume_mount
The documentation claims that g_volume_get_mount should succeed after g_volume_mount. Let's update mounts before releasing g_volume_mount to be sure that the mount is added to the corresponding volume. The same is done in GVfsUDisks2VolumeMonitor. https://gitlab.gnome.org/GNOME/glib/issues/1458
Diffstat (limited to 'gio')
-rw-r--r--gio/gunixvolume.c9
-rw-r--r--gio/gunixvolumemonitor.c19
-rw-r--r--gio/gunixvolumemonitor.h1
3 files changed, 19 insertions, 10 deletions
diff --git a/gio/gunixvolume.c b/gio/gunixvolume.c
index b54d1fd6e..a3768e11d 100644
--- a/gio/gunixvolume.c
+++ b/gio/gunixvolume.c
@@ -274,6 +274,7 @@ eject_mount_done (GObject *source,
GTask *task = user_data;
GError *error = NULL;
gchar *stderr_str;
+ GUnixVolume *unix_volume;
if (!g_subprocess_communicate_utf8_finish (subprocess, result, NULL, &stderr_str, &error))
{
@@ -286,8 +287,12 @@ eject_mount_done (GObject *source,
/* ...but bad exit code */
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "%s", stderr_str);
else
- /* ...and successful exit code */
- g_task_return_boolean (task, TRUE);
+ {
+ /* ...and successful exit code */
+ unix_volume = G_UNIX_VOLUME (g_task_get_source_object (task));
+ _g_unix_volume_monitor_update (G_UNIX_VOLUME_MONITOR (unix_volume->volume_monitor));
+ g_task_return_boolean (task, TRUE);
+ }
g_free (stderr_str);
}
diff --git a/gio/gunixvolumemonitor.c b/gio/gunixvolumemonitor.c
index b7711ff52..4b99423d7 100644
--- a/gio/gunixvolumemonitor.c
+++ b/gio/gunixvolumemonitor.c
@@ -183,15 +183,21 @@ g_unix_volume_monitor_class_init (GUnixVolumeMonitorClass *klass)
native_class->get_mount_for_mount_path = get_mount_for_mount_path;
}
+void
+_g_unix_volume_monitor_update (GUnixVolumeMonitor *unix_monitor)
+{
+ /* Update both to make sure volumes are created before mounts */
+ update_volumes (unix_monitor);
+ update_mounts (unix_monitor);
+}
+
static void
mountpoints_changed (GUnixMountMonitor *mount_monitor,
gpointer user_data)
{
GUnixVolumeMonitor *unix_monitor = user_data;
- /* Update both to make sure volumes are created before mounts */
- update_volumes (unix_monitor);
- update_mounts (unix_monitor);
+ _g_unix_volume_monitor_update (unix_monitor);
}
static void
@@ -200,9 +206,7 @@ mounts_changed (GUnixMountMonitor *mount_monitor,
{
GUnixVolumeMonitor *unix_monitor = user_data;
- /* Update both to make sure volumes are created before mounts */
- update_volumes (unix_monitor);
- update_mounts (unix_monitor);
+ _g_unix_volume_monitor_update (unix_monitor);
}
static void
@@ -219,8 +223,7 @@ g_unix_volume_monitor_init (GUnixVolumeMonitor *unix_monitor)
"mountpoints-changed", G_CALLBACK (mountpoints_changed),
unix_monitor);
- update_volumes (unix_monitor);
- update_mounts (unix_monitor);
+ _g_unix_volume_monitor_update (unix_monitor);
}
GVolumeMonitor *
diff --git a/gio/gunixvolumemonitor.h b/gio/gunixvolumemonitor.h
index 4f54fc23c..14e07fb9f 100644
--- a/gio/gunixvolumemonitor.h
+++ b/gio/gunixvolumemonitor.h
@@ -55,6 +55,7 @@ GType _g_unix_volume_monitor_get_type (void) G_GN
GVolumeMonitor * _g_unix_volume_monitor_new (void);
GUnixVolume * _g_unix_volume_monitor_lookup_volume_for_mount_path (GUnixVolumeMonitor *monitor,
const char *mount_path);
+void _g_unix_volume_monitor_update (GUnixVolumeMonitor *monitor);
G_END_DECLS