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



commit 60d44b34930e5f8e4fca1dcf0f45bad017fd9a34
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/libtracker-miner/tracker-monitor.c |   40 ++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index e9a0264..cd71c99 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -118,6 +118,11 @@ static INotifyHandle *libinotify_monitor_directory (TrackerMonitor *monitor,
 						    GFile          *file);
 static void           libinotify_monitor_cancel    (gpointer        data);
 
+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)
@@ -1082,6 +1087,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));
 		}
@@ -1142,6 +1148,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));
 		}
@@ -1381,6 +1388,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,
 			GFile          *file)



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