[tracker] tracker-miner-fs: Add --no-daemon command line to exit when indexing done



commit 3acef682c6ee2369d50cba3a3a478fc990f07694
Author: Martyn Russell <martyn lanedo com>
Date:   Fri Mar 18 12:03:46 2011 +0000

    tracker-miner-fs: Add --no-daemon command line to exit when indexing done

 docs/manpages/tracker-miner-fs.1 |    6 ++++++
 src/miners/fs/tracker-main.c     |   17 +++++++++++++++++
 2 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/docs/manpages/tracker-miner-fs.1 b/docs/manpages/tracker-miner-fs.1
index 84a5466..7c7e53c 100644
--- a/docs/manpages/tracker-miner-fs.1
+++ b/docs/manpages/tracker-miner-fs.1
@@ -30,6 +30,12 @@ Sets the logging level, 0=errors, 1=minimal, 2=detailed, 3=debug.
 .B \-s, \-\-initial-sleep=SECONDS
 Sets the initial sleep time before crawling the file system is started.
 .TP
+.B \-n, \-\-no-daemon
+Tells the miner to exit once all indexing has finished and the
+database is up to date. This is not the default mode of operation for
+the miner, usually it stays around acting like a daemon to monitor
+file updates which may occur over time.
+.TP
 .B \-e, \-\-eligible=FILE
 Checks if 
 .B FILE 
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 4df4b8a..3f2317e 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -69,6 +69,7 @@ static gboolean finished_miners;
 
 static gint verbosity = -1;
 static gint initial_sleep = -1;
+static gboolean no_daemon;
 static gchar *eligible;
 static gboolean version;
 
@@ -83,6 +84,10 @@ static GOptionEntry entries[] = {
 	  N_("Initial sleep time in seconds, "
 	     "0->1000 (default=15)"),
 	  NULL },
+	{ "no-daemon", 'n', 0,
+	  G_OPTION_ARG_NONE, &no_daemon,
+	  N_("Runs until all configured locations are indexed and then exits"),
+	  NULL },
 	{ "eligible", 'e', 0,
 	  G_OPTION_ARG_FILENAME, &eligible,
 	  N_("Checks if FILE is eligible for being mined based on configuration"),
@@ -250,6 +255,13 @@ miner_handle_next (void)
 
 		g_message ("All miners are now finished");
 
+		/* We're not sticking around for file updates, so stop
+		 * the mainloop and exit.
+		 */
+		if (no_daemon) {
+			g_main_loop_quit (main_loop);
+		}
+
 		return;
 	}
 
@@ -612,6 +624,11 @@ main (gint argc, gchar *argv[])
 
 	main_loop = g_main_loop_new (NULL, FALSE);
 
+	g_message ("Checking if we're running as a daemon:");
+	g_message ("  %s %s",
+	           no_daemon ? "No" : "Yes",
+	           no_daemon ? "(forced by command line)" : "");
+
 	/* Check if we should crawl and if we should force mtime
 	 * checking based on the config.
 	 */



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