[tracker-miners/wip/carlosg/shuffle-libtracker-miner: 67/116] libtracker-miner: Fix race which resulted in files being queued out of order



commit 7a0204246c2c8a4b62e80979318873285ffeb74b
Author: Sam Thursfield <sam afuera me uk>
Date:   Fri Jul 20 16:05:12 2018 +0200

    libtracker-miner: Fix race which resulted in files being queued out of order
    
    The TrackerFileNotifier signals need to be emitted in a heirarchical
    order. If we have this directory heirarchy...
    
        test-monitored/
        test-monitored/file1.txt
    
    ...we must always emit ::file-created for 'test-monitored/' before we emit
    ::file-created for 'test-monitored/file1.txt'.
    
    The tracker_file_notifier_ensure_parents() function ensures that we do
    this, but it would previously not work correctly in situations where
    'test-monitored/' was a configured indexing root, rather than a
    subdirectory of one of the roots.
    
    This was causing the tracker-miners functional tests to randomly fail
    with errors such as this:
    
        ** (tracker-miner-fs:18181): WARNING **: 16:01:00.461: Parent 
'file:///home/sam/tracker-tests/tmpDSmsQI/test-monitored' not indexed yet
    
    This is presumably a regression from 2e2dd4f5dc650aefa4b7188cf1a612b2d27f84ba.

 src/libtracker-miner/tracker-file-notifier.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-file-notifier.c b/src/libtracker-miner/tracker-file-notifier.c
index d90a73325..fdd6e11f3 100644
--- a/src/libtracker-miner/tracker-file-notifier.c
+++ b/src/libtracker-miner/tracker-file-notifier.c
@@ -1069,8 +1069,7 @@ tracker_file_notifier_ensure_parents (TrackerFileNotifier *notifier,
        parent = g_file_get_parent (file);
 
        while (parent) {
-               if (tracker_indexing_tree_file_is_root (priv->indexing_tree, parent) ||
-                   tracker_file_notifier_get_file_iri (notifier, parent, TRUE)) {
+               if (tracker_file_notifier_get_file_iri (notifier, parent, TRUE)) {
                        g_object_unref (parent);
                        break;
                }
@@ -1082,6 +1081,11 @@ tracker_file_notifier_ensure_parents (TrackerFileNotifier *notifier,
                g_object_unref (parent);
 
                g_signal_emit (notifier, signals[FILE_CREATED], 0, canonical);
+
+               if (tracker_indexing_tree_file_is_root (priv->indexing_tree, canonical)) {
+                       break;
+               }
+
                parent = g_file_get_parent (canonical);
        }
 }


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