[tracker/tracker-0.10] miner-fs: Consider "paused by missing store" non critical for mtime check in future runs
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.10] miner-fs: Consider "paused by missing store" non critical for mtime check in future runs
- Date: Thu, 7 Apr 2011 16:45:44 +0000 (UTC)
commit 557d3a112cecca1583857574d834061116fc1795
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Apr 5 14:31:27 2011 +0200
miner-fs: Consider "paused by missing store" non critical for mtime check in future runs
Fixes Bug 644455 - ~/.cache/tracker/no-need-mtime-check.txt is not written if
tracker-store is stopped before tracker-miner-fs, reported by Michael Biebl.
Now tracker-miner-fs will consider a safe shutdown if the only pause reason is
tracker-store missing.
.../libtracker-miner/libtracker-miner-sections.txt | 1 +
src/libtracker-miner/tracker-miner-object.c | 19 ++++
src/libtracker-miner/tracker-miner-object.h | 4 +
src/miners/fs/tracker-main.c | 88 ++++++++++++++++++--
4 files changed, 103 insertions(+), 9 deletions(-)
---
diff --git a/docs/reference/libtracker-miner/libtracker-miner-sections.txt b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
index f035b09..4f45b74 100644
--- a/docs/reference/libtracker-miner/libtracker-miner-sections.txt
+++ b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
@@ -44,6 +44,7 @@ tracker_miner_stop
tracker_miner_ignore_next_update
tracker_miner_is_started
tracker_miner_is_paused
+tracker_miner_get_n_pause_reasons
tracker_miner_pause
tracker_miner_resume
tracker_miner_get_connection
diff --git a/src/libtracker-miner/tracker-miner-object.c b/src/libtracker-miner/tracker-miner-object.c
index cb01c77..ca1fce6 100644
--- a/src/libtracker-miner/tracker-miner-object.c
+++ b/src/libtracker-miner/tracker-miner-object.c
@@ -736,6 +736,25 @@ tracker_miner_is_paused (TrackerMiner *miner)
return g_hash_table_size (miner->private->pauses) > 0 ? TRUE : FALSE;
}
+/**
+ * tracker_miner_get_n_pause_reasons:
+ * @miner: a #TrackerMiner
+ *
+ * Returns the number of pause reasons holding @miner from
+ * indexing contents.
+ *
+ * Returns: The number of current pause reasons
+ *
+ * Since: 0.10.5
+ **/
+guint
+tracker_miner_get_n_pause_reasons (TrackerMiner *miner)
+{
+ g_return_val_if_fail (TRACKER_IS_MINER (miner), 0);
+
+ return g_hash_table_size (miner->private->pauses);
+}
+
static gint
tracker_miner_pause_internal (TrackerMiner *miner,
const gchar *application,
diff --git a/src/libtracker-miner/tracker-miner-object.h b/src/libtracker-miner/tracker-miner-object.h
index f8c859e..5602360 100644
--- a/src/libtracker-miner/tracker-miner-object.h
+++ b/src/libtracker-miner/tracker-miner-object.h
@@ -93,12 +93,16 @@ void tracker_miner_ignore_next_update (TrackerMiner
const GStrv urls);
gboolean tracker_miner_is_started (TrackerMiner *miner);
gboolean tracker_miner_is_paused (TrackerMiner *miner);
+
+guint tracker_miner_get_n_pause_reasons (TrackerMiner *miner);
+
gint tracker_miner_pause (TrackerMiner *miner,
const gchar *reason,
GError **error);
gboolean tracker_miner_resume (TrackerMiner *miner,
gint cookie,
GError **error);
+
TrackerSparqlConnection *tracker_miner_get_connection (TrackerMiner *miner);
GDBusConnection *tracker_miner_get_dbus_connection (TrackerMiner *miner);
G_CONST_RETURN gchar *tracker_miner_get_dbus_full_name (TrackerMiner *miner);
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 10d126f..fb224b3 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -577,6 +577,80 @@ check_eligible (void)
g_object_unref (file);
}
+static gboolean
+store_is_available (void)
+{
+ GDBusConnection *connection;
+ GDBusProxy *proxy;
+ gchar *name_owner;
+
+ connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+
+ if (!connection) {
+ return FALSE;
+ }
+
+ proxy = g_dbus_proxy_new_sync (connection,
+ G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
+ NULL,
+ "org.freedesktop.Tracker1",
+ "/org/freedesktop/Tracker1/Status",
+ "org.freedesktop.Tracker1.Status",
+ NULL, NULL);
+
+ if (!proxy) {
+ g_object_unref (connection);
+ return FALSE;
+ }
+
+ name_owner = g_dbus_proxy_get_name_owner (proxy);
+
+ g_object_unref (connection);
+ g_object_unref (proxy);
+
+ if (name_owner) {
+ g_free (name_owner);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+miner_needs_check (TrackerMiner *miner,
+ gboolean store_available)
+{
+ /* Reasons to not mark ourselves as cleanly shutdown include:
+ *
+ * 1. Still have files to process in our queues.
+ * 2. We crash (out of our control usually anyway).
+ * 3. At least one of the miners is PAUSED, we have
+ * to exclude the situations where the miner is
+ * exclusively paused due to the store not being
+ * available, but the miner is actually done.
+ */
+ if (!tracker_miner_is_paused (miner)) {
+ if (TRACKER_IS_MINER_FS (miner) &&
+ tracker_miner_fs_has_items_to_process (TRACKER_MINER_FS (miner))) {
+ /* There are items left to process */
+ return TRUE;
+ }
+
+ /* We consider the miner finished */
+ return FALSE;
+ } else {
+ if (store_available) {
+ /* Paused for other reasons, so probably not done */
+ return TRUE;
+ } else {
+ /* Check whether there are more pause
+ * reasons than the store being out.
+ */
+ return tracker_miner_get_n_pause_reasons (miner) > 1;
+ }
+ }
+}
+
int
main (gint argc, gchar *argv[])
{
@@ -589,6 +663,7 @@ main (gint argc, gchar *argv[])
gboolean do_mtime_checking;
gboolean do_crawling;
gboolean force_mtime_checking = FALSE;
+ gboolean store_available;
g_type_init ();
@@ -754,15 +829,10 @@ main (gint argc, gchar *argv[])
g_message ("Shutdown started");
- /* Reasons to not mark ourselves as cleanly shutdown include:
- *
- * 1. Still have files to process in our queues.
- * 2. We crash (out of our control usually anyway).
- * 3. At least one of the miners is PAUSED.
- */
- if (!tracker_miner_fs_has_items_to_process (TRACKER_MINER_FS (miner_files)) &&
- !tracker_miner_is_paused (miner_applications) &&
- !tracker_miner_is_paused (miner_files)) {
+ store_available = store_is_available ();
+
+ if (!miner_needs_check (miner_files, store_available) &&
+ !miner_needs_check (miner_applications, store_available)) {
tracker_db_manager_set_need_mtime_check (FALSE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]