[tracker-miners/wip/carlosg/delete-perf: 3/5] libtracker-miner: Propagate is_dir across delete events




commit 732517cea72cf8ecf086e673a1c82c1c79f6bdc7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Dec 21 12:29:20 2020 +0100

    libtracker-miner: Propagate is_dir across delete events
    
    This information will be used for optimizations.

 src/libtracker-miner/tracker-miner-fs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index d74020bc6..4197ba700 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1176,6 +1176,7 @@ item_add_or_update (TrackerMinerFS *fs,
 static gboolean
 item_remove (TrackerMinerFS *fs,
              GFile          *file,
+             gboolean        is_dir,
              gboolean        only_children)
 {
        gchar *uri;
@@ -1227,15 +1228,17 @@ item_move (TrackerMinerFS *fs,
                     (flags & TRACKER_DIRECTORY_FLAG_RECURSE) != 0 &&
                     is_dir);
 
-       /* Delete destination item from store if any */
-       item_remove (fs, dest_file, FALSE);
+       if (!is_dir) {
+               /* Delete destination item from store if any */
+               item_remove (fs, dest_file, is_dir, FALSE);
+       }
 
        /* If the original location is recursive, but the destination location
         * is not, remove all children.
         */
        if (!recursive &&
            (source_flags & TRACKER_DIRECTORY_FLAG_RECURSE) != 0)
-               item_remove (fs, source_file, TRUE);
+               item_remove (fs, source_file, is_dir, TRUE);
 
        TRACKER_MINER_FS_GET_CLASS (fs)->move_file (fs, dest_file, source_file,
                                                    fs->priv->sparql_buffer,
@@ -1512,7 +1515,7 @@ miner_handle_next_item (TrackerMinerFS *fs)
                keep_processing = item_move (fs, file, source_file, is_dir);
                break;
        case TRACKER_MINER_FS_EVENT_DELETED:
-               keep_processing = item_remove (fs, file, FALSE);
+               keep_processing = item_remove (fs, file, is_dir, FALSE);
                break;
        case TRACKER_MINER_FS_EVENT_CREATED:
                keep_processing = item_add_or_update (fs, file, info, FALSE, TRUE);
@@ -1770,6 +1773,7 @@ file_notifier_file_deleted (TrackerFileNotifier  *notifier,
        }
 
        event = queue_event_new (TRACKER_MINER_FS_EVENT_DELETED, file, NULL);
+       event->is_dir = !!is_dir;
        miner_fs_queue_event (fs, event, miner_fs_get_queue_priority (fs, file));
 }
 


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