[tracker-miners/wip/carlosg/delete-perf: 4/5] libtracker-miner: Propagate is_dir through TrackerMinerFS::remove-file




commit 4dd4b6d92d202df52b3553d3b1748cc1b681874c
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Dec 21 12:30:11 2020 +0100

    libtracker-miner: Propagate is_dir through TrackerMinerFS::remove-file
    
    And hook it to the delete_children argument when issuing the corresponding
    SPARQL deletes. Before this, we used to delete recursively on everything
    (files and directories), with a performance hit.

 src/libtracker-miner/tracker-miner-fs.c        | 3 ++-
 src/libtracker-miner/tracker-miner-fs.h        | 3 ++-
 src/miners/fs/tracker-miner-files.c            | 8 +++++---
 tests/libtracker-miner/tracker-miner-fs-test.c | 5 +++--
 4 files changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 4197ba700..95da79702 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -1197,7 +1197,8 @@ item_remove (TrackerMinerFS *fs,
                                                                  fs->priv->sparql_buffer);
        } else {
                TRACKER_MINER_FS_GET_CLASS (fs)->remove_file (fs, file,
-                                                             fs->priv->sparql_buffer);
+                                                             fs->priv->sparql_buffer,
+                                                             is_dir);
        }
 
        g_free (uri);
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index de165157b..d76adaf1b 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -115,7 +115,8 @@ typedef struct {
                                               gint                  files_ignored);
        void     (* remove_file)              (TrackerMinerFS       *fs,
                                               GFile                *file,
-                                              TrackerSparqlBuffer  *buffer);
+                                              TrackerSparqlBuffer  *buffer,
+                                              gboolean              is_dir);
        void     (* remove_children)          (TrackerMinerFS       *fs,
                                               GFile                *file,
                                               TrackerSparqlBuffer  *buffer);
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 8b55c0251..ce5a6ed59 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -197,7 +197,8 @@ static void        miner_files_remove_children          (TrackerMinerFS       *f
                                                          TrackerSparqlBuffer  *buffer);
 static void        miner_files_remove_file              (TrackerMinerFS       *fs,
                                                          GFile                *file,
-                                                         TrackerSparqlBuffer  *buffer);
+                                                         TrackerSparqlBuffer  *buffer,
+                                                         gboolean              is_dir);
 static void        miner_files_move_file                (TrackerMinerFS       *fs,
                                                          GFile                *file,
                                                          GFile                *source_file,
@@ -2284,9 +2285,10 @@ miner_files_remove_children (TrackerMinerFS      *fs,
 static void
 miner_files_remove_file (TrackerMinerFS      *fs,
                          GFile               *file,
-                         TrackerSparqlBuffer *buffer)
+                         TrackerSparqlBuffer *buffer,
+                         gboolean             is_dir)
 {
-       add_delete_sparql (file, buffer, TRUE, TRUE);
+       add_delete_sparql (file, buffer, TRUE, is_dir);
 }
 
 static void
diff --git a/tests/libtracker-miner/tracker-miner-fs-test.c b/tests/libtracker-miner/tracker-miner-fs-test.c
index 27650d11e..8f13d764b 100644
--- a/tests/libtracker-miner/tracker-miner-fs-test.c
+++ b/tests/libtracker-miner/tracker-miner-fs-test.c
@@ -106,7 +106,8 @@ test_miner_process_file_attributes (TrackerMinerFS      *miner,
 static void
 test_miner_remove_file (TrackerMinerFS      *miner,
                         GFile               *file,
-                        TrackerSparqlBuffer *buffer)
+                        TrackerSparqlBuffer *buffer,
+                        gboolean             is_dir)
 {
        gchar *sparql, *uri;
 
@@ -153,7 +154,7 @@ test_miner_move_file (TrackerMinerFS      *miner,
                       gboolean             recursive)
 {
        /* Caution: This does not deal with recursive moves */
-       test_miner_remove_file (miner, source, buffer);
+       test_miner_remove_file (miner, source, buffer, recursive);
        test_miner_process_file (miner, dest, NULL, buffer, TRUE);
 }
 


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