[tracker] tracker-miner-fs: add an --add-file option.
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] tracker-miner-fs: add an --add-file option.
- Date: Mon, 8 Mar 2010 14:58:47 +0000 (UTC)
commit 000868a333262c1108e06ce2f27f6c85d1fcd90b
Author: Carlos Garnacho <carlos lanedo com>
Date: Mon Mar 8 15:52:30 2010 +0100
tracker-miner-fs: add an --add-file option.
This command line paramenter will force the insertion of an specific
file into the store, by spawning a config-less TrackerMinerFiles and
feeding it the file directly.
src/tracker-miner-fs/tracker-main.c | 56 ++++++++++++++++++++++++++---------
1 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/src/tracker-miner-fs/tracker-main.c b/src/tracker-miner-fs/tracker-main.c
index 7142502..f8e323c 100644
--- a/src/tracker-miner-fs/tracker-main.c
+++ b/src/tracker-miner-fs/tracker-main.c
@@ -70,6 +70,7 @@ static gboolean finished_miners;
static gint verbosity = -1;
static gint initial_sleep = -1;
static gchar *eligible;
+static gchar *add_file;
static gboolean version;
static GOptionEntry entries[] = {
@@ -87,6 +88,10 @@ static GOptionEntry entries[] = {
G_OPTION_ARG_FILENAME, &eligible,
N_("Checks if FILE is eligible for being mined based on configuration"),
N_("FILE") },
+ { "add-file", 'a', 0,
+ G_OPTION_ARG_FILENAME, &add_file,
+ N_("Forces the insertion of FILE into the store"),
+ N_("FILE") },
{ "version", 'V', 0,
G_OPTION_ARG_NONE, &version,
N_("Displays version information"),
@@ -203,6 +208,7 @@ miner_handle_next (void)
finished_miners = TRUE;
g_message ("All miners are now finished");
+
return;
}
@@ -221,11 +227,20 @@ miner_finished_cb (TrackerMinerFS *fs,
guint total_files_ignored,
gpointer user_data)
{
+ GMainLoop *main_loop = user_data;
+
g_message ("Finished mining in seconds:%f, total directories:%d, total files:%d",
seconds_elapsed,
total_directories_found,
total_files_found);
+ if (add_file && main_loop) {
+ /* We were waiting for a file to be processed, now it's safe to quit */
+ GMainLoop *main_loop = user_data;
+ g_main_loop_quit (main_loop);
+ return;
+ }
+
miner_handle_next ();
}
@@ -583,7 +598,23 @@ main (gint argc, gchar *argv[])
return EXIT_FAILURE;
}
- miner_files = tracker_miner_files_new (config);
+ main_loop = g_main_loop_new (NULL, FALSE);
+
+ if (!add_file) {
+ miner_files = tracker_miner_files_new (config);
+ } else {
+ GFile *file;
+
+ file = g_file_new_for_commandline_arg (add_file);
+ miner_files = tracker_miner_files_new (NULL);
+
+ tracker_miner_fs_file_add (TRACKER_MINER_FS (miner_files), file);
+ g_object_unref (file);
+ }
+
+ g_signal_connect (miner_files, "finished",
+ G_CALLBACK (miner_finished_cb),
+ main_loop);
object = tracker_miner_files_reindex_new (TRACKER_MINER_FILES (miner_files));
@@ -607,26 +638,23 @@ main (gint argc, gchar *argv[])
return EXIT_FAILURE;
}
- /* Create miner for applications */
- miner_applications = tracker_miner_applications_new ();
- miners = g_slist_append (miners, miner_applications);
+ if (!add_file) {
+ /* Create miner for applications */
+ miner_applications = tracker_miner_applications_new ();
+ miners = g_slist_append (miners, miner_applications);
- g_signal_connect (miner_applications, "finished",
- G_CALLBACK (miner_finished_cb),
- NULL);
+ g_signal_connect (miner_applications, "finished",
+ G_CALLBACK (miner_finished_cb),
+ NULL);
- /* Create miner for files */
- miners = g_slist_append (miners, miner_files);
-
- g_signal_connect (miner_files, "finished",
- G_CALLBACK (miner_finished_cb),
- NULL);
+ /* Create miner for files */
+ miners = g_slist_append (miners, miner_files);
+ }
tracker_thumbnailer_init ();
miner_handle_next ();
- main_loop = g_main_loop_new (NULL, FALSE);
g_main_loop_run (main_loop);
g_message ("Shutdown started");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]