[tracker-miners/wip/carlosg/delay-monitors: 13/19] tracker-miner-fs: Drop handling of mtime checks




commit 43fa93f0403506febb01d8acd57ce777f6e5a550
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Nov 8 18:35:17 2020 +0100

    tracker-miner-fs: Drop handling of mtime checks
    
    This goes nowhere now, we can avoid all checks about whether enabling
    mtime checks or not.

 src/miners/fs/tracker-main.c        |  53 ++----------------
 src/miners/fs/tracker-miner-files.c | 105 ------------------------------------
 src/miners/fs/tracker-miner-files.h |  15 ------
 3 files changed, 4 insertions(+), 169 deletions(-)
---
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index f7896e439..c4574c2fd 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -329,8 +329,7 @@ initialize_priority_and_scheduling (void)
 
 static gboolean
 should_crawl (TrackerMinerFiles *miner_files,
-              TrackerConfig     *config,
-              gboolean          *forced)
+              TrackerConfig     *config)
 {
        gint crawling_interval;
 
@@ -346,11 +345,6 @@ should_crawl (TrackerMinerFiles *miner_files,
                return TRUE;
        } else if (crawling_interval == 0) {
                TRACKER_NOTE (CONFIG, g_message ("  Forced"));
-
-               if (forced) {
-                       *forced = TRUE;
-               }
-
                return TRUE;
        } else {
                guint64 then, now;
@@ -404,17 +398,10 @@ miner_start_idle_cb (gpointer data)
 
 static void
 miner_start (TrackerMiner  *miner,
-            TrackerConfig *config,
-            gboolean       do_mtime_checking)
+            TrackerConfig *config)
 {
        gint initial_sleep;
 
-       if (!do_mtime_checking) {
-               g_debug ("Avoiding initial sleep, no mtime check needed");
-               miner_maybe_start (miner);
-               return;
-       }
-
        /* If requesting to run as no-daemon, start right away */
        if (no_daemon) {
                miner_maybe_start (miner);
@@ -954,8 +941,6 @@ main (gint argc, gchar *argv[])
        TrackerMiner *miner_files;
        GOptionContext *context;
        GError *error = NULL;
-       gboolean do_mtime_checking;
-       gboolean force_mtime_checking = FALSE;
        TrackerMinerProxy *proxy;
        GDBusConnection *connection;
        TrackerSparqlConnection *sparql_conn;
@@ -1119,36 +1104,7 @@ main (gint argc, gchar *argv[])
        /* Check if we should crawl and if we should force mtime
         * checking based on the config.
         */
-       do_crawling = should_crawl (TRACKER_MINER_FILES (miner_files),
-                                   config, &force_mtime_checking);
-
-       /* Get the last shutdown state to see if we need to perform a
-        * full mtime check against the db or not.
-        *
-        * Set to TRUE here in case we crash and miss file system
-        * events.
-        */
-       TRACKER_NOTE (CONFIG, g_message ("Checking whether to force mtime checking during crawling (based on 
last clean shutdown):"));
-
-       /* Override the shutdown state decision based on the config */
-       if (force_mtime_checking) {
-               do_mtime_checking = TRUE;
-       } else {
-               do_mtime_checking = tracker_miner_files_get_need_mtime_check (TRACKER_MINER_FILES 
(miner_files));
-       }
-
-       TRACKER_NOTE (CONFIG, g_message ("  %s %s",
-                             do_mtime_checking ? "Yes" : "No",
-                             force_mtime_checking ? "(forced from config)" : ""));
-
-       /* Set the need for an mtime check to TRUE so we check in the
-        * event of a crash, this is changed back on shutdown if
-        * everything appears to be fine.
-        */
-       if (!dry_run) {
-               tracker_miner_files_set_need_mtime_check (TRACKER_MINER_FILES (miner_files), TRUE);
-               tracker_miner_files_set_mtime_checking (TRACKER_MINER_FILES (miner_files), do_mtime_checking);
-       }
+       do_crawling = should_crawl (TRACKER_MINER_FILES (miner_files), config);
 
        g_signal_connect (miner_files, "started",
                          G_CALLBACK (miner_started_cb),
@@ -1173,7 +1129,7 @@ main (gint argc, gchar *argv[])
                                                NULL, graphs_created_cb, miner_files);
 
        if (do_crawling)
-               miner_start (miner_files, config, do_mtime_checking);
+               miner_start (miner_files, config);
 
        initialize_signal_handler ();
 
@@ -1183,7 +1139,6 @@ main (gint argc, gchar *argv[])
        g_debug ("Shutdown started");
 
        if (!dry_run && miners_timeout_id == 0 && !miner_needs_check (miner_files)) {
-               tracker_miner_files_set_need_mtime_check (TRACKER_MINER_FILES (miner_files), FALSE);
                save_current_locale (domain_ontology);
        }
 
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 3a18d441e..2b5d4d3f6 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -51,7 +51,6 @@
 /* Stamp files to know crawling/indexing state */
 #define FIRST_INDEX_FILENAME          "first-index.txt"
 #define LAST_CRAWL_FILENAME           "last-crawl.txt"
-#define NEED_MTIME_CHECK_FILENAME     "no-need-mtime-check.txt"
 
 #define DEFAULT_GRAPH "tracker:FileSystem"
 
@@ -98,7 +97,6 @@ struct TrackerMinerFilesPrivate {
 
        guint force_recheck_id;
 
-       gboolean mtime_check;
        gboolean index_removable_devices;
        gboolean index_optical_discs;
        guint volumes_changed_id;
@@ -357,8 +355,6 @@ tracker_miner_files_init (TrackerMinerFiles *mf)
                          G_CALLBACK (mount_pre_unmount_cb),
                          mf);
 
-       priv->mtime_check = TRUE;
-
        rdf_types = tracker_extract_module_manager_get_all_rdf_types ();
        rdf_types_str = g_strjoinv (",", rdf_types);
        g_strfreev (rdf_types);
@@ -2800,104 +2796,3 @@ tracker_miner_files_set_last_crawl_done (TrackerMinerFiles *mf,
        }
        g_free (filename);
 }
-
-inline static gchar *
-get_need_mtime_check_filename (TrackerMinerFiles *mf)
-{
-       GFile *file;
-       gchar *prefix, *path;
-
-       file = get_cache_dir (mf);
-       prefix = g_file_get_path (file);
-
-       path = g_build_filename (prefix,
-                                NEED_MTIME_CHECK_FILENAME,
-                                NULL);
-       g_free (prefix);
-       g_object_unref (file);
-
-       return path;
-}
-
-/**
- * tracker_miner_files_get_need_mtime_check:
- *
- * Check if the miner-fs was cleanly shutdown or not.
- *
- * Returns: %TRUE if we need to check mtimes for directories against
- * the database on the next start for the miner-fs, %FALSE otherwise.
- **/
-gboolean
-tracker_miner_files_get_need_mtime_check (TrackerMinerFiles *mf)
-{
-       gboolean exists;
-       gchar *filename;
-
-       filename = get_need_mtime_check_filename (mf);
-       exists = g_file_test (filename, G_FILE_TEST_EXISTS);
-       g_free (filename);
-
-       /* Existence of the file means we cleanly shutdown before and
-        * don't need to do the mtime check again on this start.
-        */
-       return !exists;
-}
-
-/**
- * tracker_miner_files_set_need_mtime_check:
- * @needed: a #gboolean
- *
- * If the next start of miner-fs should perform a full mtime check
- * against each directory found and those in the database (for
- * complete synchronisation), then @needed should be #TRUE, otherwise
- * #FALSE.
- *
- * Creates a file in $HOME/.cache/tracker/ if an mtime check is not
- * needed. The idea behind this is that a check is forced if the file
- * is not cleaned up properly on shutdown (i.e. due to a crash or any
- * other uncontrolled shutdown reason).
- **/
-void
-tracker_miner_files_set_need_mtime_check (TrackerMinerFiles *mf,
-                                         gboolean           needed)
-{
-       gboolean already_exists;
-       gchar *filename;
-
-       filename = get_need_mtime_check_filename (mf);
-       already_exists = g_file_test (filename, G_FILE_TEST_EXISTS);
-
-       /* !needed = add file
-        *  needed = remove file
-        */
-       if (!needed && !already_exists) {
-               GError *error = NULL;
-
-               /* Create stamp file if not already there */
-               if (!g_file_set_contents (filename, PACKAGE_VERSION, -1, &error)) {
-                       g_warning ("  Could not create file:'%s' failed, %s",
-                                  filename,
-                                  error->message);
-                       g_error_free (error);
-               } else {
-                       g_info ("  Need mtime check file:'%s' created", filename);
-               }
-       } else if (needed && already_exists) {
-               /* Remove stamp file */
-               g_info ("  Removing need mtime check file:'%s'", filename);
-
-               if (g_remove (filename)) {
-                       g_warning ("    Could not remove file:'%s': %m",
-                                  filename);
-               }
-       }
-
-       g_free (filename);
-}
-
-void
-tracker_miner_files_set_mtime_checking (TrackerMinerFiles *mf,
-                                        gboolean           mtime_check)
-{
-       mf->private->mtime_check = mtime_check;
-}
diff --git a/src/miners/fs/tracker-miner-files.h b/src/miners/fs/tracker-miner-files.h
index 7198147b1..6053c9b10 100644
--- a/src/miners/fs/tracker-miner-files.h
+++ b/src/miners/fs/tracker-miner-files.h
@@ -62,21 +62,6 @@ guint64  tracker_miner_files_get_last_crawl_done  (TrackerMinerFiles *mf);
 void     tracker_miner_files_set_last_crawl_done  (TrackerMinerFiles *mf,
                                                    gboolean           done);
 
-gboolean tracker_miner_files_get_need_mtime_check (TrackerMinerFiles *mf);
-void     tracker_miner_files_set_need_mtime_check (TrackerMinerFiles *mf,
-                                                   gboolean           needed);
-
-void     tracker_miner_files_set_mtime_checking   (TrackerMinerFiles *miner,
-                                                   gboolean           mtime_checking);
-
-void     tracker_miner_files_writeback_file       (TrackerMinerFiles *mf,
-                                                   GFile             *file,
-                                                   GStrv              rdf_types,
-                                                   GPtrArray         *results);
-void     tracker_miner_files_writeback_notify     (TrackerMinerFiles *mf,
-                                                   GFile             *file,
-                                                   const GError      *error);
-
 G_END_DECLS
 
 #endif /* __TRACKER_MINER_FS_FILES_H__ */


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