[tracker/miner-fs-refactor: 71/119] libtracker-miner: Add a "preserve in store" flag for config dirs



commit df603cb558b04d1703aeeb0af7f35f509e57d8fd
Author: Carlos Garnacho <carlos lanedo com>
Date:   Tue Oct 4 11:45:00 2011 +0200

    libtracker-miner: Add a "preserve in store" flag for config dirs
    
    And use it for mounts, so the info is preserved in the store, and
    only tracker:available is unset in TrackerMinerFiles.

 src/libtracker-miner/tracker-file-notifier.c |   15 ++++++++++++++-
 src/libtracker-miner/tracker-indexing-tree.c |    4 ++--
 src/libtracker-miner/tracker-miner-enums.h   |    1 +
 src/libtracker-miner/tracker-miner-fs.c      |    3 ++-
 4 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index c25cb8e..c859520 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -939,7 +939,20 @@ indexing_tree_directory_removed (TrackerIndexingTree *indexing_tree,
                                  GFile               *directory,
                                  gpointer             user_data)
 {
-	/* Signal as removed? depends on delete vs unmount */
+	TrackerFileNotifier *notifier = user_data;
+	TrackerFileNotifierPrivate *priv = notifier->priv;
+	TrackerDirectoryFlags flags;
+
+	/* Flags are still valid at the moment of deletion */
+	tracker_indexing_tree_get_root (indexing_tree, directory, &flags);
+
+	if ((flags & TRACKER_DIRECTORY_FLAG_PRESERVE) == 0) {
+		/* Directory needs to be deleted from the store too */
+		g_signal_emit (notifier, signals[FILE_DELETED], 0, directory);
+	}
+
+	/* Remove monitors if any */
+	tracker_monitor_remove_recursively (priv->monitor, directory);
 }
 
 static void
diff --git a/src/libtracker-miner/tracker-indexing-tree.c b/src/libtracker-miner/tracker-indexing-tree.c
index 9c4a15a..da2704d 100644
--- a/src/libtracker-miner/tracker-indexing-tree.c
+++ b/src/libtracker-miner/tracker-indexing-tree.c
@@ -443,6 +443,8 @@ tracker_indexing_tree_remove (TrackerIndexingTree *tree,
 		return;
 	}
 
+	g_signal_emit (tree, signals[DIRECTORY_REMOVED], 0, directory);
+
 	parent = node->parent;
 	g_node_unlink (node);
 
@@ -450,8 +452,6 @@ tracker_indexing_tree_remove (TrackerIndexingTree *tree,
 	g_node_children_foreach (node, G_TRAVERSE_ALL,
 	                         check_reparent_node, parent);
 
-	g_signal_emit (tree, signals[DIRECTORY_REMOVED], 0, directory);
-
 	node_data_free (node->data);
 	g_node_destroy (node);
 }
diff --git a/src/libtracker-miner/tracker-miner-enums.h b/src/libtracker-miner/tracker-miner-enums.h
index 0f14adf..cdaf9e5 100644
--- a/src/libtracker-miner/tracker-miner-enums.h
+++ b/src/libtracker-miner/tracker-miner-enums.h
@@ -30,6 +30,7 @@ typedef enum {
 	TRACKER_DIRECTORY_FLAG_CHECK_MTIME = 1 << 2,
 	TRACKER_DIRECTORY_FLAG_MONITOR     = 1 << 3,
 	TRACKER_DIRECTORY_FLAG_IGNORE      = 1 << 4,
+	TRACKER_DIRECTORY_FLAG_PRESERVE    = 1 << 5
 } TrackerDirectoryFlags;
 
 typedef enum {
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 39a1e6c..c6f36f3 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -3680,7 +3680,8 @@ tracker_miner_fs_add_directory_without_parent (TrackerMinerFS *fs,
 	                           file,
 	                           TRACKER_DIRECTORY_FLAG_RECURSE |
 	                           TRACKER_DIRECTORY_FLAG_CHECK_MTIME |
-	                           TRACKER_DIRECTORY_FLAG_MONITOR);
+	                           TRACKER_DIRECTORY_FLAG_MONITOR |
+	                           TRACKER_DIRECTORY_FLAG_PRESERVE);
 }
 
 /**



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