summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam@afuera.me.uk>2018-07-15 15:40:17 +0200
committerSam Thursfield <sam@afuera.me.uk>2018-07-15 15:43:14 +0200
commit13cf183c43751c5a817abc63360aa85857342b82 (patch)
tree5669ba4a2e5375c62fb371ccf08e386408c48eda
parentda005c5171184ec198d635418c31462a2c272519 (diff)
downloadtracker-sam/tracker-miner-fs-test-fixes.tar.gz
libtracker-miner: Warn when overwriting tasks in the task poolsam/tracker-miner-fs-test-fixes
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
-rw-r--r--src/libtracker-miner/tracker-task-pool.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libtracker-miner/tracker-task-pool.c b/src/libtracker-miner/tracker-task-pool.c
index f66d4b694..c17d961be 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));