[tracker/mounts-without-volumes] tracker-miner-fs: Only check if exist those files which didn't have mtime check



commit 747de5d5be9b2cd0335b8e3885e6b232b440146b
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Thu Jun 10 15:35:34 2010 +0200

    tracker-miner-fs: Only check if exist those files which didn't have mtime check

 src/libtracker-miner/tracker-miner-fs.c |   55 +++++++++++++++++++++++++++---
 1 files changed, 49 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index da40877..ff494a6 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -133,6 +133,9 @@ struct TrackerMinerFSPrivate {
 	/* File -> iri cache */
 	GHashTable     *iri_cache;
 
+	/* Files to check if no longer exist */
+	GHashTable     *check_removed;
+
 	/* Status */
 	guint           been_started : 1;
 	guint           been_crawled : 1;
@@ -555,6 +558,11 @@ tracker_miner_fs_init (TrackerMinerFS *object)
 	                                         (GDestroyNotify) g_object_unref,
 	                                         (GDestroyNotify) g_free);
 
+	priv->check_removed = g_hash_table_new_full (g_file_hash,
+	                                             (GEqualFunc) g_file_equal,
+	                                             (GDestroyNotify) g_object_unref,
+	                                             NULL);
+
 	priv->mtime_checking = TRUE;
 	priv->initial_crawling = TRUE;
 }
@@ -689,6 +697,10 @@ fs_finalize (GObject *object)
 		g_hash_table_unref (priv->iri_cache);
 	}
 
+	if (priv->check_removed) {
+		g_hash_table_unref (priv->check_removed);
+	}
+
 	G_OBJECT_CLASS (tracker_miner_fs_parent_class)->finalize (object);
 }
 
@@ -2240,10 +2252,33 @@ remove_unexisting_file_cb (gpointer key,
 		g_debug ("Removing file which no longer exists in FS: %s",
 		         g_file_get_uri (file));
 		item_remove (fs, file);
-		return TRUE;
 	}
 
-	return FALSE;
+	return TRUE;
+}
+
+static void
+check_if_files_removed (TrackerMinerFS *fs)
+{
+	g_debug ("Checking if any file was removed...");
+	g_hash_table_foreach_remove (fs->private->check_removed,
+	                             remove_unexisting_file_cb,
+	                             fs);
+}
+
+static void
+add_to_check_removed_cb (gpointer key,
+                         gpointer value,
+                         gpointer user_data)
+{
+	TrackerMinerFS *fs = user_data;
+	GFile *file = key;
+
+	/* Not adding any data to the value, we just want
+	 *  fast search for key availability */
+	g_hash_table_insert (fs->private->check_removed,
+	                     g_object_ref (file),
+	                     NULL);
 }
 
 static void
@@ -2328,10 +2363,11 @@ ensure_mtime_cache (TrackerMinerFS *fs,
 	g_main_loop_unref (data.main_loop);
 	g_hash_table_unref (data.values);
 
-	/* Look for files which no longer exist in the FS... */
-	g_hash_table_foreach_remove (fs->private->mtime_cache,
-	                             remove_unexisting_file_cb,
-	                             fs);
+
+	/* Iterate repopulated HT and add all to the check_removed HT */
+	g_hash_table_foreach (fs->private->mtime_cache,
+	                      add_to_check_removed_cb,
+	                      fs);
 }
 
 static gboolean
@@ -2358,6 +2394,9 @@ should_change_index_for_file (TrackerMinerFS *fs,
 		return TRUE;
 	}
 
+	/* Remove the file from the list of files to be checked if removed */
+	g_hash_table_remove (fs->private->check_removed, file);
+
 	file_info = g_file_query_info (file,
 	                               G_FILE_ATTRIBUTE_TIME_MODIFIED,
 	                               G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
@@ -2838,6 +2877,10 @@ crawler_finished_cb (TrackerCrawler *crawler,
 	directory_data_unref (fs->private->current_directory);
 	fs->private->current_directory = NULL;
 
+	/* Check if any file was left after whole
+	 *  crawling */
+	check_if_files_removed (fs);
+
 	/* Proceed to next thing to process */
 	crawl_directories_start (fs);
 }



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