[tracker/miner-fs-refactor: 24/74] libtracker-miner: Make TrackerMinerFS use TrackerIndexingTree
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-fs-refactor: 24/74] libtracker-miner: Make TrackerMinerFS use TrackerIndexingTree
- Date: Tue, 4 Oct 2011 10:52:28 +0000 (UTC)
commit c8b9c1804974f1853911a9eed440b5c06cdb7889
Author: Carlos Garnacho <carlos lanedo com>
Date: Thu Sep 8 16:40:06 2011 +0200
libtracker-miner: Make TrackerMinerFS use TrackerIndexingTree
No more check-* or monitor-directory signals are emitted. Instead,
the TrackerIndexingTree is used to determine whether files should
be indexed.
src/libtracker-miner/tracker-miner-fs.c | 74 +++++++++++++++++++-----------
1 files changed, 47 insertions(+), 27 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 6520604..626fded 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -722,6 +722,31 @@ tracker_miner_fs_class_init (TrackerMinerFSClass *klass)
}
static void
+indexing_tree_directory_added_cb (TrackerIndexingTree *tree,
+ GFile *directory,
+ gpointer user_data)
+{
+ TrackerMinerFS *fs = user_data;
+ TrackerDirectoryFlags dir_flags;
+ gboolean recurse;
+
+ tracker_indexing_tree_get_root (tree, directory, &dir_flags);
+ recurse = (dir_flags & TRACKER_DIRECTORY_FLAG_RECURSE) != 0;
+
+ tracker_miner_fs_directory_add (fs, directory, recurse);
+}
+
+static void
+indexing_tree_directory_removed_cb (TrackerIndexingTree *tree,
+ GFile *directory,
+ gpointer user_data)
+{
+ TrackerMinerFS *fs = user_data;
+
+ tracker_miner_fs_directory_remove (fs, directory);
+}
+
+static void
tracker_miner_fs_init (TrackerMinerFS *object)
{
TrackerMinerFSPrivate *priv;
@@ -755,6 +780,12 @@ tracker_miner_fs_init (TrackerMinerFS *object)
/* Create the indexing tree */
priv->indexing_tree = tracker_indexing_tree_new ();
+ g_signal_connect (priv->indexing_tree, "directory-added",
+ G_CALLBACK (indexing_tree_directory_added_cb),
+ object);
+ g_signal_connect (priv->indexing_tree, "directory-removed",
+ G_CALLBACK (indexing_tree_directory_removed_cb),
+ object);
/* Set up the crawlers now we have config and hal */
priv->crawler = tracker_crawler_new ();
@@ -3497,15 +3528,11 @@ should_check_file (TrackerMinerFS *fs,
GFile *file,
gboolean is_dir)
{
- gboolean should_check;
+ GFileType file_type;
- if (is_dir) {
- g_signal_emit (fs, signals[CHECK_DIRECTORY], 0, file, &should_check);
- } else {
- g_signal_emit (fs, signals[CHECK_FILE], 0, file, &should_check);
- }
-
- return should_check;
+ file_type = (is_dir) ? G_FILE_TYPE_DIRECTORY : G_FILE_TYPE_REGULAR;
+ return tracker_indexing_tree_file_is_indexable (fs->priv->indexing_tree,
+ file, file_type);
}
static gboolean
@@ -4129,10 +4156,15 @@ crawler_check_directory_contents_cb (TrackerCrawler *crawler,
gboolean add_monitor = FALSE;
gboolean process;
- g_signal_emit (fs, signals[CHECK_DIRECTORY_CONTENTS], 0, parent, children, &process);
-
+ process = tracker_indexing_tree_parent_is_indexable (fs->priv->indexing_tree,
+ parent, children);
if (process) {
- g_signal_emit (fs, signals[MONITOR_DIRECTORY], 0, parent, &add_monitor);
+ TrackerDirectoryFlags parent_flags;
+
+ tracker_indexing_tree_get_root (fs->priv->indexing_tree,
+ parent, &parent_flags);
+
+ add_monitor = (parent_flags & TRACKER_DIRECTORY_FLAG_MONITOR) != 0;
/* If the directory crawled doesn't have ANY file, we need to
* force a mtime cache reload using the given directory as input
@@ -4486,24 +4518,12 @@ static gboolean
should_recurse_for_directory (TrackerMinerFS *fs,
GFile *file)
{
- gboolean recurse = FALSE;
- GList *dirs;
+ TrackerDirectoryFlags flags;
- for (dirs = fs->priv->config_directories; dirs; dirs = dirs->next) {
- DirectoryData *data;
-
- data = dirs->data;
-
- if (data->recurse &&
- (g_file_equal (file, data->file) ||
- g_file_has_prefix (file, data->file))) {
- /* File is inside a recursive dir */
- recurse = TRUE;
- break;
- }
- }
+ tracker_indexing_tree_get_root (fs->priv->indexing_tree,
+ file, &flags);
- return recurse;
+ return (flags & TRACKER_DIRECTORY_FLAG_RECURSE) != 0;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]