[tracker: 5/6] Fix max_depth parameter causing contents of a directory to be ignored



commit 7789afdc2ebe60e39d5931cfcc3aec60d0f4b971
Author: Sam Thursfield <sam afuera me uk>
Date:   Wed Dec 24 16:22:03 2014 +0000

    Fix max_depth parameter causing contents of a directory to be ignored
    
    Since commit 41e6ab84e7a540b20f8173c2bbaee11de6ef381f, the contents of
    directories listed in 'index-single-directories' is be ignored. The
    directory itself appears in the store but the contents do not.
    
    The intention of passing max_depth=1 if TRACKER_DIRECTORY_FLAG_RECURSE
    is false must be to prevent unnecessarily processing any subdirectory
    nodes that are hanging around in the TrackerFileSystem. However, the
    documentation of g_node_traverse says:
    
        "If depth is 1, only the root is visited. If depth is 2, the root
        and its children are visited. And so on."
    
    Thus, we must pass max_depth+1 to the tracker_file_system_traverse()
    function so that the files in the directory are processed as well as
    the directory itself.
    
    See also: 243c97fa96a2f6b19bce1acf26946d1a516a0a1c which introduced the
    'max_depth' parameter as a way of reducing the number of GFile objects
    in memory at the same time during crawling.

 src/libtracker-miner/tracker-file-notifier.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index 1cddc56..b82b43a 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -360,13 +360,18 @@ file_notifier_traverse_tree (TrackerFileNotifier *notifier, gint max_depth)
        config_root = tracker_indexing_tree_get_root (priv->indexing_tree,
                                                      directory, &flags);
 
+       /* The max_depth parameter is usually '1', which would cause only the
+        * directory itself to be processed. We want the directory and its contents
+        * to be processed so we need to go to (max_depth + 1) here.
+        */
+
        if (config_root != directory ||
            flags & TRACKER_DIRECTORY_FLAG_CHECK_MTIME) {
                tracker_file_system_traverse (priv->file_system,
                                              directory,
                                              G_LEVEL_ORDER,
                                              file_notifier_traverse_tree_foreach,
-                                             max_depth,
+                                             max_depth + 1,
                                              notifier);
        }
 }


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