[tracker-miners/wip/carlosg/shuffle-libtracker-miner: 66/116] libtracker-miner: Warn when overwriting tasks in the task pool



commit c77935a1be8e8728fbf839165090fa5bfb3f7524
Author: Sam Thursfield <sam afuera me uk>
Date:   Sun Jul 15 15:40:17 2018 +0200

    libtracker-miner: Warn when overwriting tasks in the task pool
    
    The TrackerTaskPool class and its subclass TrackerSparqlBuffer are
    designed to contain only one task for any given GFile.
    
    If multiple tasks are pushed for the same file some of them might
    not be executed. This leads to issues such as:
    https://gitlab.gnome.org/GNOME/tracker/issues/15

 src/libtracker-miner/tracker-task-pool.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/src/libtracker-miner/tracker-task-pool.c b/src/libtracker-miner/tracker-task-pool.c
index b03dff026..93c42964a 100644
--- a/src/libtracker-miner/tracker-task-pool.c
+++ b/src/libtracker-miner/tracker-task-pool.c
@@ -218,11 +218,22 @@ tracker_task_pool_add (TrackerTaskPool *pool,
                        TrackerTask     *task)
 {
        TrackerTaskPoolPrivate *priv;
+       GFile *file;
 
        g_return_if_fail (TRACKER_IS_TASK_POOL (pool));
 
        priv = pool->priv;
 
+       file = tracker_task_get_file (task);
+
+       if (g_hash_table_contains (priv->tasks, file)) {
+               /* This is bad! We use the task's associated GFile as the key for the
+                * hash table, so if there's already a value we are about to overwrite
+                * it. This suggests there's a bug in the tracker-miner-fs.c code.
+                */
+               g_warning ("Multiple update tasks for file %s", g_file_get_uri (file));
+       };
+
        g_hash_table_insert (priv->tasks,
                             tracker_task_get_file (task),
                             tracker_task_ref (task));


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