[tracker-miners/wip/carlosg/perf-squeeze: 4/16] libtracker-miner: Rework pre-caching of information element URNs



commit 81d0dfbd708c5351cf099a78c398a197f7281bb5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Jul 4 13:44:51 2020 +0200

    libtracker-miner: Rework pre-caching of information element URNs
    
    The use of information element URNs is pretty much reserved now to
    folders. We can avoid trying to cache it for every file, we also
    need to do it preemptively on less situations.

 src/libtracker-miner/tracker-file-notifier.c |  6 ++++++
 src/libtracker-miner/tracker-miner-fs.c      | 23 ++++++++++++++++-------
 2 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 5768d141d..b83b52c87 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -1085,6 +1085,12 @@ monitor_item_updated_cb (TrackerMonitor *monitor,
        /* Fetch the interned copy */
        canonical = tracker_file_system_get_file (priv->file_system,
                                                  file, file_type, NULL);
+
+       if (is_directory) {
+               /* Ensure the folder iri is cached */
+               tracker_file_notifier_get_file_iri (notifier, canonical, TRUE);
+       }
+
        g_signal_emit (notifier, signals[FILE_UPDATED], 0, canonical, FALSE);
 
        if (!is_directory) {
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 70464176e..30e8c8d27 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1249,6 +1249,18 @@ update_processing_task_context_free (UpdateProcessingTaskContext *ctxt)
        g_slice_free (UpdateProcessingTaskContext, ctxt);
 }
 
+static void
+cache_parent_folder_urn (TrackerMinerFS *fs,
+                        GFile          *file)
+{
+       GFile *parent;
+
+       parent = g_file_get_parent (file);
+       tracker_file_notifier_get_file_iri (fs->priv->file_notifier,
+                                           parent, TRUE);
+       g_object_unref (parent);
+}
+
 static void
 on_signal_gtask_complete (GObject      *source,
                          GAsyncResult *res,
@@ -1511,6 +1523,10 @@ item_move (TrackerMinerFS *fs,
            (source_flags & TRACKER_DIRECTORY_FLAG_RECURSE) != 0)
                item_remove (fs, source_file, TRUE, source_task_sparql);
 
+       /* Cache URN for source/dest folders */
+       cache_parent_folder_urn (fs, source_file);
+       cache_parent_folder_urn (fs, dest_file);
+
        g_signal_emit (fs, signals[MOVE_FILE], 0, dest_file, source_file, recursive, &sparql);
 
        if (sparql && sparql[0] != '\0') {
@@ -2059,10 +2075,6 @@ miner_fs_queue_event (TrackerMinerFS *fs,
                                                               (GDestroyNotify) queue_event_free);
                }
 
-               /* Ensure IRI is cached */
-               tracker_file_notifier_get_file_iri (fs->priv->file_notifier,
-                                                   event->file, TRUE);
-
                trace_eq_event (event);
 
                link = tracker_priority_queue_add (fs->priv->items, event, priority);
@@ -2390,9 +2402,6 @@ tracker_miner_fs_check_file (TrackerMinerFS *fs,
                        return;
                }
 
-               tracker_file_notifier_get_file_iri (fs->priv->file_notifier,
-                                                   file, TRUE);
-
                event = queue_event_new (TRACKER_MINER_FS_EVENT_UPDATED, file);
                trace_eq_event (event);
                miner_fs_queue_event (fs, event, priority);


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