[tracker/wip/miner-fs-refactor: 51/55] libtracker-miner: Hook up progress/status indication to TrackerFileNotifier processing



commit e3dea96d6e34b43f69176028ec0f489923345e2c
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Sep 30 12:04:04 2011 +0200

    libtracker-miner: Hook up progress/status indication to TrackerFileNotifier processing

 src/libtracker-miner/tracker-miner-fs.c |   59 +++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index aab344b..936cc8c 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -337,6 +337,15 @@ static void           file_notifier_file_moved            (TrackerFileNotifier
                                                            GFile                *source,
                                                            GFile                *dest,
                                                            gpointer              user_data);
+static void           file_notifier_directory_finished    (TrackerFileNotifier *notifier,
+                                                           GFile               *directory,
+                                                           guint                directories_found,
+                                                           guint                directories_ignored,
+                                                           guint                files_found,
+                                                           guint                files_ignored,
+                                                           gpointer             user_data);
+static void           file_notifier_finished              (TrackerFileNotifier *notifier,
+                                                           gpointer             user_data);
 
 static gboolean       crawler_check_file_cb               (TrackerCrawler       *crawler,
                                                            GFile                *file,
@@ -786,10 +795,17 @@ tracker_miner_fs_init (TrackerMinerFS *object)
 	g_signal_connect (priv->file_notifier, "file-moved",
 	                  G_CALLBACK (file_notifier_file_moved),
 	                  object);
+	g_signal_connect (priv->file_notifier, "directory-finished",
+	                  G_CALLBACK (file_notifier_directory_finished),
+	                  object);
+	g_signal_connect (priv->file_notifier, "finished",
+	                  G_CALLBACK (file_notifier_finished),
+	                  object);
 
 	/* Set up the crawlers now we have config and hal */
 	priv->crawler = tracker_crawler_new ();
 
+#if 0
 	g_signal_connect (priv->crawler, "check-file",
 	                  G_CALLBACK (crawler_check_file_cb),
 	                  object);
@@ -805,6 +821,7 @@ tracker_miner_fs_init (TrackerMinerFS *object)
 	g_signal_connect (priv->crawler, "finished",
 	                  G_CALLBACK (crawler_finished_cb),
 	                  object);
+#endif
 
 
 	priv->quark_ignore_file = g_quark_from_static_string ("tracker-ignore-file");
@@ -2818,8 +2835,11 @@ item_queue_get_next_file (TrackerMinerFS  *fs,
 
 	if (fs->priv->is_crawling ||
 	    fs->priv->crawl_directories_id != 0 ||
+	    tracker_file_notifier_is_active (fs->priv->file_notifier) ||
+#if 0
 	    !tracker_priority_queue_is_empty (fs->priv->crawled_directories) ||
 	    !tracker_priority_queue_is_empty (fs->priv->directories) ||
+#endif
 	    tracker_task_pool_limit_reached (fs->priv->task_pool) ||
 	    tracker_task_pool_limit_reached (TRACKER_TASK_POOL (fs->priv->sparql_buffer))) {
 		/* There are still pending items to crawl,
@@ -3564,6 +3584,41 @@ file_notifier_file_moved (TrackerFileNotifier *notifier,
 	}
 }
 
+static void
+file_notifier_directory_finished (TrackerFileNotifier *notifier,
+                                  GFile               *directory,
+                                  guint                directories_found,
+                                  guint                directories_ignored,
+                                  guint                files_found,
+                                  guint                files_ignored,
+                                  gpointer             user_data)
+{
+	TrackerMinerFS *fs = user_data;
+
+	/* Update stats */
+	fs->priv->directories_found += directories_found;
+	fs->priv->directories_ignored += directories_ignored;
+	fs->priv->files_found += files_found;
+	fs->priv->files_ignored += files_ignored;
+
+	fs->priv->total_directories_found += directories_found;
+	fs->priv->total_directories_ignored += directories_ignored;
+	fs->priv->total_files_found += files_found;
+	fs->priv->total_files_ignored += files_ignored;
+}
+
+static void
+file_notifier_finished (TrackerFileNotifier *notifier,
+                        gpointer             user_data)
+{
+	TrackerMinerFS *fs = user_data;
+
+	if (!tracker_miner_fs_has_items_to_process (fs)) {
+		g_message ("Finished content crawling");
+		process_stop (fs);
+	}
+}
+
 static gboolean
 crawler_check_file_cb (TrackerCrawler *crawler,
                        GFile          *file,
@@ -4003,6 +4058,7 @@ tracker_miner_fs_directory_add_internal (TrackerMinerFS *fs,
                                          GFile          *file,
                                          gint            priority)
 {
+#if 0
 	DirectoryData *data;
 	gboolean recurse;
 
@@ -4022,6 +4078,7 @@ tracker_miner_fs_directory_add_internal (TrackerMinerFS *fs,
 	}
 
 	directory_data_unref (data);
+#endif
 }
 
 /**
@@ -4055,6 +4112,7 @@ tracker_miner_fs_directory_add (TrackerMinerFS *fs,
 			               directory_data_ref (dir_data));
 	}
 
+#if 0
 	/* If not already in the list to process, add it */
 	if (tracker_priority_queue_find (fs->priv->directories,
 	                                 NULL,
@@ -4068,6 +4126,7 @@ tracker_miner_fs_directory_add (TrackerMinerFS *fs,
 	}
 
 	directory_data_unref (dir_data);
+#endif
 }
 
 static void



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