[tracker-miners/wip/carlosg/speed-track: 34/40] libtracker-miner: Early out on unchanged files




commit 682b2380d0e52eaa71ca55a72d0025dcf9a59936
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Oct 17 15:58:16 2020 +0200

    libtracker-miner: Early out on unchanged files
    
    Instead of accumulating these files. Remove them from the TrackerFileNotifier
    queues as soon as we know the file is unchanged, and at a time we have the
    data/node handy.

 src/libtracker-miner/tracker-file-notifier.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index dc1a00c1d..3bc9626ef 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -425,6 +425,7 @@ file_notifier_add_node_foreach (GNode    *node,
                return FALSE;
 
        if (file_info) {
+               TrackerFileData *file_data;
                GFileType file_type;
                guint64 _time;
 
@@ -432,10 +433,18 @@ file_notifier_add_node_foreach (GNode    *node,
                _time = g_file_info_get_attribute_uint64 (file_info,
                                                          G_FILE_ATTRIBUTE_TIME_MODIFIED);
 
-               _insert_disk_info (notifier,
-                                  file,
-                                  file_type,
-                                  _time);
+               file_data = _insert_disk_info (notifier,
+                                              file,
+                                              file_type,
+                                              _time);
+
+               if (file_data->state == FILE_STATE_NONE) {
+                       /* If at this point the file has no assigned event,
+                        * it didn't get changed, and can be ignored.
+                        */
+                       g_queue_delete_link (&priv->queue, file_data->node);
+                       g_hash_table_remove (priv->cache, file);
+               }
 
                if (file_type == G_FILE_TYPE_DIRECTORY &&
                    (priv->current_index_root->flags & TRACKER_DIRECTORY_FLAG_RECURSE) != 0 &&


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