[tracker/miner-fs-rename-directory-to-hidden-name] libtracker-miner: Don't add monitors when renaming a directory to a hidden name



commit 0ffbc1b760defad2899b1ada1bd517f5f0208b6f
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Mon Dec 13 10:16:00 2010 +0100

    libtracker-miner: Don't add monitors when renaming a directory to a hidden name

 src/libtracker-miner/tracker-miner-fs.c |   17 ++++++++++++++---
 src/libtracker-miner/tracker-monitor.c  |   11 ++++-------
 src/libtracker-miner/tracker-monitor.h  |    3 +++
 3 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index a79f1dd..aff61e9 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -3120,15 +3120,26 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
 				tracker_miner_fs_directory_add_internal (fs, other_file);
 			}
 		} else if (!should_process_other) {
-			/* Delete old file */
-			g_queue_push_tail (fs->private->items_deleted, g_object_ref (file));
+			/* Remove monitors if any */
+			if (is_directory) {
+				tracker_monitor_remove_recursively (fs->private->monitor,
+				                                    file);
+			}
 
+			/* Delete old file */
+			g_queue_push_tail (fs->private->items_deleted,
+			                   g_object_ref (file));
 			item_queue_handlers_set_up (fs);
 		} else {
+			/* Move monitors to the new place */
+			if (is_directory) {
+				tracker_monitor_move (fs->private->monitor,
+				                      file,
+				                      other_file);
+			}
 			/* Move old file to new file */
 			g_queue_push_tail (fs->private->items_moved,
 			                   item_moved_data_new (other_file, file));
-
 			item_queue_handlers_set_up (fs);
 		}
 
diff --git a/src/libtracker-miner/tracker-monitor.c b/src/libtracker-miner/tracker-monitor.c
index 43c1f54..ff5c1fc 100644
--- a/src/libtracker-miner/tracker-monitor.c
+++ b/src/libtracker-miner/tracker-monitor.c
@@ -495,7 +495,7 @@ event_data_free (gpointer data)
 	g_slice_free (EventData, data);
 }
 
-static gboolean
+gboolean
 tracker_monitor_move (TrackerMonitor *monitor,
                       GFile          *old_file,
                       GFile          *new_file)
@@ -677,12 +677,9 @@ emit_signal_for_event (TrackerMonitor *monitor,
 		               event_data->other_file,
 		               event_data->is_directory,
 		               TRUE);
-		/* Move monitors to the new place */
-		if (event_data->is_directory) {
-			tracker_monitor_move (monitor,
-			                      event_data->file,
-			                      event_data->other_file);
-		}
+		/* Note that in any case we should be moving the monitors
+		 * here to the new place, as the new place may be ignored.
+		 * We should leave this to the upper layers. */
 		break;
 
 	case G_FILE_MONITOR_EVENT_PRE_UNMOUNT:
diff --git a/src/libtracker-miner/tracker-monitor.h b/src/libtracker-miner/tracker-monitor.h
index 2cd9eaa..accca05 100644
--- a/src/libtracker-miner/tracker-monitor.h
+++ b/src/libtracker-miner/tracker-monitor.h
@@ -61,6 +61,9 @@ gboolean        tracker_monitor_remove               (TrackerMonitor *monitor,
                                                       GFile          *file);
 gboolean        tracker_monitor_remove_recursively   (TrackerMonitor *monitor,
                                                       GFile          *file);
+gboolean        tracker_monitor_move                 (TrackerMonitor *monitor,
+                                                      GFile          *old_file,
+                                                      GFile          *new_file);
 gboolean        tracker_monitor_is_watched           (TrackerMonitor *monitor,
                                                       GFile          *file);
 gboolean        tracker_monitor_is_watched_by_string (TrackerMonitor *monitor,



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