[tracker/libtracker-miner] Don't use been_started AND process_dir_id and emit finished signal
- From: Martyn James Russell <mr src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker/libtracker-miner] Don't use been_started AND process_dir_id and emit finished signal
- Date: Tue, 25 Aug 2009 12:55:36 +0000 (UTC)
commit 6ccbb2b7017b18c730c8964954f417aab4674440
Author: Martyn Russell <martyn lanedo com>
Date: Tue Aug 25 13:48:53 2009 +0100
Don't use been_started AND process_dir_id and emit finished signal
src/libtracker-miner/tracker-miner-process.c | 60 +++++++++++++++++---------
1 files changed, 39 insertions(+), 21 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-process.c b/src/libtracker-miner/tracker-miner-process.c
index 0bfc60d..c140e2b 100644
--- a/src/libtracker-miner/tracker-miner-process.c
+++ b/src/libtracker-miner/tracker-miner-process.c
@@ -64,7 +64,6 @@ struct TrackerMinerProcessPrivate {
guint process_dirs_id;
/* Status */
- guint been_started : 1;
guint shown_totals : 1;
/* Statistics */
@@ -1138,13 +1137,7 @@ process_directories_cb (gpointer user_data)
}
if (!miner->private->directories) {
- /* Now we have finished crawling, print stats and enable monitor events */
- print_stats (miner);
-
- g_message ("Enabling monitor events");
- tracker_monitor_set_enabled (miner->private->monitor, TRUE);
-
- miner->private->process_dirs_id = 0;
+ process_directories_stop (miner);
return FALSE;
}
@@ -1173,22 +1166,20 @@ static void
process_directories_start (TrackerMinerProcess *process)
{
if (process->private->process_dirs_id != 0) {
+ /* Processing ALREADY going on */
return;
}
- if (!process->private->been_started) {
- process->private->been_started = TRUE;
- process->private->timer = g_timer_new ();
-
- process->private->total_directories_found = 0;
- process->private->total_directories_ignored = 0;
- process->private->total_files_found = 0;
- process->private->total_files_ignored = 0;
- process->private->directories_found = 0;
- process->private->directories_ignored = 0;
- process->private->files_found = 0;
- process->private->files_ignored = 0;
- }
+ process->private->timer = g_timer_new ();
+
+ process->private->total_directories_found = 0;
+ process->private->total_directories_ignored = 0;
+ process->private->total_files_found = 0;
+ process->private->total_files_ignored = 0;
+ process->private->directories_found = 0;
+ process->private->directories_ignored = 0;
+ process->private->files_found = 0;
+ process->private->files_ignored = 0;
process->private->process_dirs_id = g_idle_add (process_directories_cb, process);
}
@@ -1196,10 +1187,37 @@ process_directories_start (TrackerMinerProcess *process)
static void
process_directories_stop (TrackerMinerProcess *process)
{
+ if (process->private->process_dirs_id == 0) {
+ /* No processing going on, nothing to stop */
+ return;
+ }
+
if (process->private->current_directory) {
tracker_crawler_stop (process->private->crawler);
}
+ /* Now we have finished crawling, print stats and enable monitor events */
+ print_stats (process);
+
+ g_message ("Enabling monitor events");
+ tracker_monitor_set_enabled (process->private->monitor, TRUE);
+
+ /* Is this the right time to emit FINISHED? What about
+ * monitor events left to handle? Should they matter
+ * here?
+ */
+ g_signal_emit (process, signals[FINISHED], 0,
+ g_timer_elapsed (process->private->timer, NULL),
+ process->private->total_directories_found,
+ process->private->total_directories_ignored,
+ process->private->total_files_found,
+ process->private->total_files_ignored);
+
+ if (process->private->timer) {
+ g_timer_destroy (process->private->timer);
+ process->private->timer = NULL;
+ }
+
if (process->private->process_dirs_id != 0) {
g_source_remove (process->private->process_dirs_id);
process->private->process_dirs_id = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]