[tracker-miners/wip/carlosg/speed-track: 10/40] libtracker-miner: Handle move events from ineligible sources deeper




commit 4dca8f641e9ad154a0aafc9523570511adbf4b0f
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Oct 4 18:35:07 2020 +0200

    libtracker-miner: Handle move events from ineligible sources deeper
    
    At the TrackerFileNotifier level, we just check that the file is in
    the TrackerFileSystem, even though it's not guaranteed that only eligible
    files will get there. Later on, we have checks at the TrackerMinerFS
    level to handle these move events we let through as if the destination file
    were new. We can let TrackerFileNotifier issue ::file-created instead of
    ::file-moved then.
    
    If we trust the event flow, we should not get move events for files that
    we didn't now about earlier (either previously from the database, or recently
    from events that were handled right before this one), so the checks at the
    TrackerMinerFS level become moot.

 src/libtracker-miner/tracker-file-notifier.c | 13 ++++++-----
 src/libtracker-miner/tracker-miner-fs.c      | 32 ++--------------------------
 2 files changed, 10 insertions(+), 35 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 770948092..7594800bb 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -1262,7 +1262,7 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
                }
                /* else, file, do nothing */
        } else {
-               gboolean source_stored, should_process_other;
+               gboolean should_process, should_process_other;
                GFileType file_type;
                GFile *check_file;
 
@@ -1277,8 +1277,9 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
                /* If the (parent) directory is in
                 * the filesystem, file is stored
                 */
-               source_stored = (tracker_file_system_peek_file (priv->file_system,
-                                                               check_file) != NULL);
+               should_process = tracker_indexing_tree_file_is_indexable (priv->indexing_tree,
+                                                                         file,
+                                                                         file_type);
                should_process_other = tracker_indexing_tree_file_is_indexable (priv->indexing_tree,
                                                                                other_file,
                                                                                file_type);
@@ -1295,8 +1296,10 @@ monitor_item_moved_cb (TrackerMonitor *monitor,
                g_object_ref (file);
                g_object_ref (other_file);
 
-               if (!source_stored) {
-                       /* Destination location should be indexed as if new */
+               if (!should_process) {
+                       /* The source was not an indexable file, the destination
+                        * could be though, it should be indexed as if new, then */
+
                        /* Remove monitors if any */
                        if (is_directory) {
                                tracker_monitor_remove_recursively (priv->monitor,
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index ea1b49073..7ef2aa431 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1442,7 +1442,6 @@ item_move (TrackerMinerFS *fs,
 {
        gchar     *uri, *source_uri, *sparql;
        GFileInfo *file_info;
-       gboolean source_exists;
        TrackerDirectoryFlags source_flags, flags;
        gboolean recursive;
 
@@ -1455,41 +1454,14 @@ item_move (TrackerMinerFS *fs,
                                       G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
                                       NULL, NULL);
 
-       /* Get 'source' ID */
-       source_exists = tracker_file_notifier_query_file_exists (fs->priv->file_notifier,
-                                                                source_file);
-
        if (!file_info) {
                gboolean retval;
 
-               if (source_exists) {
-                       /* Destination file has gone away, ignore dest file and remove source if any */
-                       retval = item_remove (fs, source_file, FALSE, source_task_sparql);
-               } else {
-                       /* Destination file went away, and source wasn't indexed either */
-                       retval = TRUE;
-               }
-
-               g_free (source_uri);
-               g_free (uri);
-
-               return retval;
-       } else if (!source_exists) {
-               gboolean retval;
-
-               /* The source file might not be indexed yet (eg. temporary save
-                * files that are immediately renamed to the definitive path).
-                * Deal with those as newly added items.
-                */
-               TRACKER_NOTE (MINER_FS_EVENTS,
-                             g_message ("Source file '%s' not yet in store, indexing '%s' "
-                                        "from scratch", source_uri, uri));
-
-               retval = item_add_or_update (fs, dest_file, G_PRIORITY_DEFAULT, FALSE);
+               /* Destination file has gone away, ignore dest file and remove source if any */
+               retval = item_remove (fs, source_file, FALSE, source_task_sparql);
 
                g_free (source_uri);
                g_free (uri);
-               g_object_unref (file_info);
 
                return retval;
        }


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