[glib/glib-2-56: 1/3] gio: Update mounts after g_volume_mount
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-56: 1/3] gio: Update mounts after g_volume_mount
- Date: Thu, 9 Aug 2018 14:52:39 +0000 (UTC)
commit f9ab355896993bb930c929bd0ddc3ace1b895cbe
Author: Ondrej Holy <oholy redhat com>
Date: Mon Jul 30 15:26:31 2018 +0200
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.
(Backported from commit 9b6b282e0a9d3f37865aa36e21ea57bd2a326e20 with no
merge conflicts.)
https://gitlab.gnome.org/GNOME/glib/issues/1458
gio/gunixvolume.c | 9 +++++++--
gio/gunixvolumemonitor.c | 19 +++++++++++--------
gio/gunixvolumemonitor.h | 1 +
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]