[tracker/tracker-0.6] Bug NB#136770 - Not able to see the pictures captured with camera application after renaming the cur



commit a62307f1bf24e4ad0a09970c4bc5155366c1379c
Author: Carlos Garnacho <carlos lanedo com>
Date:   Thu Sep 3 14:21:11 2009 +0200

    Bug NB#136770 - Not able to see the pictures captured with camera application after renaming the current folder.
    
    Turns out the monitor wasn't replacing the GFile (used as the key) in the
    monitors hash table after a move operation, so monitoring a newly created
    folder with the same name would fail silently.

 src/trackerd/tracker-monitor.c |   40 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/src/trackerd/tracker-monitor.c b/src/trackerd/tracker-monitor.c
index dafa89b..ecf75fd 100644
--- a/src/trackerd/tracker-monitor.c
+++ b/src/trackerd/tracker-monitor.c
@@ -126,6 +126,11 @@ static INotifyHandle *libinotify_monitor_directory (TrackerMonitor *monitor,
 static void           libinotify_monitor_cancel    (gpointer        data);
 #endif /* USE_LIBINOTIFY */
 
+static void           tracker_monitor_update       (TrackerMonitor *monitor,
+						    const gchar    *module_name,
+						    GFile          *old_file,
+						    GFile          *new_file);
+
 static guint signals[LAST_SIGNAL] = { 0, };
 
 G_DEFINE_TYPE(TrackerMonitor, tracker_monitor, G_TYPE_OBJECT)
@@ -1226,6 +1231,7 @@ libinotify_monitor_event_cb (INotifyHandle *handle,
 				       other_file,
 				       is_directory, 
 				       TRUE);
+			tracker_monitor_update (monitor, module_name, file, other_file);
 			g_hash_table_remove (monitor->private->event_pairs,
 					     GUINT_TO_POINTER (cookie));
 		}
@@ -1289,6 +1295,7 @@ libinotify_monitor_event_cb (INotifyHandle *handle,
 				       file,
 				       is_directory,
 				       is_source_indexed);
+			tracker_monitor_update (monitor, module_name, other_file, file);
 			g_hash_table_remove (monitor->private->event_pairs,
 					     GUINT_TO_POINTER (cookie));
 		}
@@ -1647,6 +1654,39 @@ tracker_monitor_add (TrackerMonitor *monitor,
 	return TRUE;
 }
 
+static void
+tracker_monitor_update (TrackerMonitor *monitor,
+			const gchar    *module_name,
+			GFile          *old_file,
+			GFile          *new_file)
+{
+	GHashTable *monitors;
+	gpointer    file_monitor;
+
+	monitors = g_hash_table_lookup (monitor->private->modules, module_name);
+
+	if (!monitors) {
+		g_warning ("No monitor hash table for module:'%s'", module_name);
+		return;
+	}
+
+	file_monitor = g_hash_table_lookup (monitors, old_file);
+
+	if (!file_monitor) {
+		gchar *path;
+
+		path = g_file_get_path (old_file);
+		g_warning ("No monitor was found for directory:'%s'", path);
+		g_free (path);
+
+		return;
+	}
+
+	/* Replace key in monitors hashtable */
+	g_hash_table_steal (monitors, old_file);
+	g_hash_table_insert (monitors, new_file, file_monitor);
+}
+
 gboolean
 tracker_monitor_remove (TrackerMonitor *monitor,
 			const gchar    *module_name,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]