[tracker-miners/wip/carlosg/delay-monitors: 16/19] tracker-miner-fs: Trigger a re-check 5m after first index




commit 57dd92c0f5ed91fc8a03847c953a7c829fb76326
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Nov 8 20:35:28 2020 +0100

    tracker-miner-fs: Trigger a re-check 5m after first index
    
    Since we are changing the strategy adding directory monitors, we
    made a larger room for race conditions where files/folders are
    added/changed, but missed.
    
    Add this timeout 5m after finishing, in order to ensure nothing is
    missing.

 src/miners/fs/tracker-miner-files.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 654759742..f8df81340 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -1688,6 +1688,22 @@ miner_files_force_recheck_idle (gpointer user_data)
        return G_SOURCE_REMOVE;
 }
 
+static void
+tracker_miner_files_trigger_check_delayed (TrackerMinerFiles *mf,
+                                           guint              seconds)
+{
+       if (mf->private->force_recheck_id != 0)
+               g_source_remove (mf->private->force_recheck_id);
+
+       if (seconds == 0) {
+               mf->private->force_recheck_id =
+                       g_idle_add (miner_files_force_recheck_idle, mf);
+       } else {
+               mf->private->force_recheck_id =
+                       g_timeout_add_seconds (seconds, miner_files_force_recheck_idle, mf);
+       }
+}
+
 static void
 trigger_recheck_cb (GObject    *gobject,
                     GParamSpec *arg1,
@@ -1697,11 +1713,8 @@ trigger_recheck_cb (GObject    *gobject,
 
        TRACKER_NOTE (CONFIG, g_message ("Ignored content related configuration changed, checking index..."));
 
-       if (mf->private->force_recheck_id == 0) {
-               /* Set idle so multiple changes in the config lead to one recheck */
-               mf->private->force_recheck_id =
-                       g_idle_add (miner_files_force_recheck_idle, mf);
-       }
+       /* Set idle so multiple changes in the config lead to one recheck */
+       tracker_miner_files_trigger_check_delayed (mf, 0);
 }
 
 static gboolean
@@ -2238,9 +2251,14 @@ miner_files_finished (TrackerMinerFS *fs,
                       gint            files_found,
                       gint            files_ignored)
 {
-       tracker_miner_files_set_last_crawl_done (TRACKER_MINER_FILES (fs), TRUE);
+       TrackerMinerFiles *mf = TRACKER_MINER_FILES (fs);
+
+       tracker_miner_files_check_unextracted (mf);
 
-       tracker_miner_files_check_unextracted (TRACKER_MINER_FILES (fs));
+       /* Schedule a re-check in a "short" period, in case we missed
+        * anything due to e.g. race conditions in crawling/monitoring.
+        */
+       tracker_miner_files_trigger_check_delayed (mf, 5 * 60);
 }
 
 static gchar *


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