From 70a4301660b81ecd7dc13845bfa14b625fe2e311 Mon Sep 17 00:00:00 2001
From: Lionel Le Folgoc <lionel@lefolgoc.net>
Date: Thu, 1 Nov 2012 19:56:16 +0100
Subject: [PATCH] Don't add duplicates of devices (bug #9440).

On some setups the volume-added singal is emitted after the
devices have been added, resulting in devices appear twice
in the sidepane.
---
 thunar/thunar-device-monitor.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/thunar/thunar-device-monitor.c b/thunar/thunar-device-monitor.c
index b6c64ba5e..a246b9580 100644
--- a/thunar/thunar-device-monitor.c
+++ b/thunar/thunar-device-monitor.c
@@ -476,6 +476,14 @@ thunar_device_monitor_volume_added (GVolumeMonitor      *volume_monitor,
   _thunar_return_if_fail (monitor->volume_monitor == volume_monitor);
   _thunar_return_if_fail (G_IS_VOLUME (volume));
 
+  /* check that the volume is not in the internal list already */
+  if (g_list_find (monitor->hidden_volumes, volume) != NULL)
+    return;
+
+  /* nor in the list of visible volumes */
+  if (g_hash_table_lookup (monitor->devices, volume) != NULL)
+    return;
+
   /* add to internal list */
   monitor->hidden_volumes = g_list_prepend (monitor->hidden_volumes, g_object_ref (volume));
 
@@ -621,6 +629,10 @@ thunar_device_monitor_mount_added (GVolumeMonitor      *volume_monitor,
   _thunar_return_if_fail (monitor->volume_monitor == volume_monitor);
   _thunar_return_if_fail (G_IS_MOUNT (mount));
 
+  /* check if the mount is not already known */
+  if (g_hash_table_lookup (monitor->devices, mount) != NULL)
+    return;
+
   /* never handle shadowed mounts */
   if (g_mount_is_shadowed (mount))
     return;
-- 
GitLab