From 5638a3a670fd1a97edf9d226afd6625ba329a11d Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 30 Aug 2010 12:06:58 +0200 Subject: libtracker-miner: if CREATED event is received from the monitor, force IRI cache update * The issue comes from NB#188494, but it doesn't fully fix it. The issue seems to be that the camera application is also inserting a new element in the store and doesn't check if it already exists before. --- src/libtracker-miner/tracker-miner-fs.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c index ffc963cf4..70c55b2d3 100644 --- a/src/libtracker-miner/tracker-miner-fs.c +++ b/src/libtracker-miner/tracker-miner-fs.c @@ -1423,7 +1423,8 @@ item_add_or_update_cb (TrackerMinerFS *fs, static gboolean item_add_or_update (TrackerMinerFS *fs, - GFile *file) + GFile *file, + gboolean force_cache_update) { TrackerMinerFSPrivate *priv; TrackerSparqlBuilder *sparql; @@ -1444,7 +1445,8 @@ item_add_or_update (TrackerMinerFS *fs, parent = g_file_get_parent (file); if (parent) { - if (!fs->private->current_iri_cache_parent || + if (force_cache_update || + !fs->private->current_iri_cache_parent || !g_file_equal (parent, fs->private->current_iri_cache_parent)) { /* Cache the URN for the new current parent, processing * order guarantees that all contents for a folder are @@ -1497,6 +1499,26 @@ item_add_or_update (TrackerMinerFS *fs, return retval; } +static gboolean +item_add (TrackerMinerFS *fs, + GFile *file) +{ + /* We force cache update when new item creations, so that we try to + * avoid duplicates if the item was already created in the store by + * an external application */ + return item_add_or_update (fs, file, TRUE); +} + +static gboolean +item_update (TrackerMinerFS *fs, + GFile *file) +{ + /* When getting UPDATE events, don't force cache updates, just follow + * the standard rules. */ + return item_add_or_update (fs, file, FALSE); +} + + static gboolean item_remove (TrackerMinerFS *fs, GFile *file) @@ -1789,7 +1811,7 @@ item_move (TrackerMinerFS *fs, tracker_miner_fs_directory_add_internal (fs, file); retval = TRUE; } else { - retval = item_add_or_update (fs, file); + retval = item_add (fs, file); } g_free (source_uri); @@ -2275,8 +2297,10 @@ item_queue_handlers_cb (gpointer user_data) keep_processing = item_remove (fs, file); break; case QUEUE_CREATED: + keep_processing = item_add (fs, file); + break; case QUEUE_UPDATED: - keep_processing = item_add_or_update (fs, file); + keep_processing = item_update (fs, file); break; case QUEUE_IGNORE_NEXT_UPDATE: keep_processing = item_ignore_next_update (fs, file, source_file); -- cgit v1.2.1