[tracker/live-config-changes: 1/6] TrackerMinerFS: Keep added directories around.



commit eb9fe5db3edf6073291431cfd84961f36033e996
Author: Carlos Garnacho <carlos lanedo com>
Date:   Mon Mar 1 17:40:18 2010 +0100

    TrackerMinerFS: Keep added directories around.
    
    Now data added through tracker_miner_fs_directory_add() is
    kept around, and the crawler is just handed a const reference
    to it.

 src/libtracker-miner/tracker-miner-fs.c |   35 ++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 5a5bce3..d2ba5f3 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -102,6 +102,8 @@ struct TrackerMinerFSPrivate {
 
 	GQuark          quark_ignore_file;
 
+	GList          *config_directories;
+
 	GList          *directories;
 	DirectoryData  *current_directory;
 
@@ -605,10 +607,14 @@ fs_finalize (GObject *object)
 	g_free (priv->current_parent_urn);
 
 	if (priv->directories) {
-		g_list_foreach (priv->directories, (GFunc) directory_data_free, NULL);
 		g_list_free (priv->directories);
 	}
 
+	if (priv->config_directories) {
+		g_list_foreach (priv->config_directories, (GFunc) directory_data_free, NULL);
+		g_list_free (priv->config_directories);
+	}
+
 	g_queue_foreach (priv->crawled_directories, (GFunc) crawled_directory_data_free, NULL);
 	g_queue_free (priv->crawled_directories);
 
@@ -2458,7 +2464,6 @@ crawler_finished_cb (TrackerCrawler *crawler,
 	           was_interrupted ? "Stopped" : "Finished",
 	           g_timer_elapsed (fs->private->timer, NULL));
 
-	directory_data_free (fs->private->current_directory);
 	fs->private->current_directory = NULL;
 
 	/* Proceed to next thing to process */
@@ -2515,7 +2520,6 @@ crawl_directories_cb (gpointer user_data)
 	}
 
 	/* Directory couldn't be processed */
-	directory_data_free (fs->private->current_directory);
 	fs->private->current_directory = NULL;
 
 	return TRUE;
@@ -2582,12 +2586,18 @@ tracker_miner_fs_directory_add (TrackerMinerFS *fs,
                                 GFile          *file,
                                 gboolean        recurse)
 {
+	DirectoryData *dir_data;
+
 	g_return_if_fail (TRACKER_IS_MINER_FS (fs));
 	g_return_if_fail (G_IS_FILE (file));
 
+	dir_data = directory_data_new (file, recurse);
+
+	fs->private->config_directories =
+		g_list_append (fs->private->config_directories, dir_data);
+
 	fs->private->directories =
-		g_list_append (fs->private->directories,
-		               directory_data_new (file, recurse));
+		g_list_append (fs->private->directories, dir_data);
 
 	crawl_directories_start (fs);
 }
@@ -2659,12 +2669,27 @@ tracker_miner_fs_directory_remove (TrackerMinerFS *fs,
 
 		if (g_file_equal (file, data->file) ||
 		    g_file_has_prefix (file, data->file)) {
+			fs->private->directories = g_list_delete_link (fs->private->directories, link);
+			return_val = TRUE;
+		}
+	}
+
+	dirs = fs->private->config_directories;
+
+	while (dirs) {
+		DirectoryData *data = dirs->data;
+		GList *link = dirs;
+
+		dirs = dirs->next;
+
+		if (g_file_equal (file, data->file)) {
 			directory_data_free (data);
 			fs->private->directories = g_list_delete_link (fs->private->directories, link);
 			return_val = TRUE;
 		}
 	}
 
+
 	/* Remove anything contained in the removed directory
 	 * from all relevant processing queues.
 	 */



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