From d73bb5fb601a761744f05c213f70b6cddce889f3 Mon Sep 17 00:00:00 2001 From: Alexander Schwinn Date: Sat, 12 Jan 2019 21:46:45 +0100 Subject: [PATCH] Thunar sometimes mounts USB drives with root permission (Bug #14719) --- thunar/thunar-device-monitor.c | 3 +++ thunar/thunar-device.c | 30 ++++++++++++++++++++++++++++++ thunar/thunar-device.h | 2 ++ 3 files changed, 35 insertions(+) diff --git a/thunar/thunar-device-monitor.c b/thunar/thunar-device-monitor.c index 0e4da6067..a825e1c11 100644 --- a/thunar/thunar-device-monitor.c +++ b/thunar/thunar-device-monitor.c @@ -616,6 +616,9 @@ thunar_device_monitor_mount_added (GVolumeMonitor *volume_monitor, device = g_hash_table_lookup (monitor->devices, volume); if (device != NULL) { + /* reload the related ThunarFile */ + thunar_device_reload_file (device); + /* notify */ g_signal_emit (G_OBJECT (monitor), device_monitor_signals[DEVICE_CHANGED], 0, device); } diff --git a/thunar/thunar-device.c b/thunar/thunar-device.c index a31091233..4933e344c 100644 --- a/thunar/thunar-device.c +++ b/thunar/thunar-device.c @@ -823,3 +823,33 @@ thunar_device_eject (ThunarDevice *device, g_object_unref (G_OBJECT (mount)); } } + + + +/** + * thunar_device_reload_file: + * + * Reload the related #ThunarFile of the #ThunarDevice + **/ +void +thunar_device_reload_file (ThunarDevice *device) +{ + ThunarFile *file; + GFile *mount_point; + + _thunar_return_if_fail (THUNAR_IS_DEVICE (device)); + + mount_point = thunar_device_get_root (device); + + if (mount_point != NULL) + { + /* try to determine the file for the mount point */ + file = thunar_file_get (mount_point, NULL); + if (file != NULL) + { + thunar_file_reload (file); + g_object_unref (file); + } + g_object_unref (mount_point); + } +} diff --git a/thunar/thunar-device.h b/thunar/thunar-device.h index bd5f16d75..536a4eab9 100644 --- a/thunar/thunar-device.h +++ b/thunar/thunar-device.h @@ -89,6 +89,8 @@ void thunar_device_eject (ThunarDevice *devic ThunarDeviceCallback callback, gpointer user_data); +void thunar_device_reload_file (ThunarDevice *device); + G_END_DECLS #endif /* !__THUNAR_DEVICE_H__ */