summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2010-05-20 14:20:40 +0200
committerMartyn Russell <martyn@lanedo.com>2010-05-20 16:20:07 +0100
commit0a0289555939b12809b262d86cc6c3ab043f6b0d (patch)
tree48c89ff407e1fe11ff82ff7f4bf404651bab6fcb
parent88ed614d33e2130a11a66ca4dec1b9c4bb19ff01 (diff)
downloadtracker-0a0289555939b12809b262d86cc6c3ab043f6b0d.tar.gz
TrackerMinerFS: Fix mtime cache for crawl directories themselves.
Mtime cache works by querying the parent folder, but for crawl directories there wouldn't be any data for its parent folder, needlessly reindexing these again, and leaving orphaned urns in the database. This problem would add up in consecutive runs, as direct children nfo:belongsToContainer would still point to the orphaned node, thus spreading the problem through the hierarchy.
-rw-r--r--src/libtracker-miner/tracker-miner-fs.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 6bf2a0c9c..3986a1b03 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -2155,6 +2155,29 @@ item_queue_handlers_set_up (TrackerMinerFS *fs)
fs);
}
+static gboolean
+file_is_crawl_directory (TrackerMinerFS *fs,
+ GFile *file)
+{
+ GList *dirs;
+
+ /* Check whether file is a crawl directory itself */
+ dirs = fs->private->config_directories;
+
+ while (dirs) {
+ DirectoryData *data;
+
+ data = dirs->data;
+ dirs = dirs->next;
+
+ if (g_file_equal (data->file, file)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
static void
ensure_mtime_cache (TrackerMinerFS *fs,
GFile *file)
@@ -2205,12 +2228,37 @@ ensure_mtime_cache (TrackerMinerFS *fs,
NULL,
cache_query_cb,
&data);
+ g_free (query);
g_main_loop_run (data.main_loop);
+ if (g_hash_table_size (data.values) == 0 &&
+ file_is_crawl_directory (fs, file)) {
+ /* File is a crawl directory itself, query its mtime directly */
+ uri = g_file_get_uri (file);
+
+ g_debug ("Folder %s is a crawl directory, generating mtime cache for it", uri);
+
+ query = g_strdup_printf ("SELECT ?url ?last "
+ "WHERE { "
+ " ?u nfo:fileLastModified ?last ; "
+ " nie:url ?url ; "
+ " nie:url \"%s\" "
+ "}", uri);
+ g_free (uri);
+
+ tracker_miner_execute_sparql (TRACKER_MINER (fs),
+ query,
+ NULL,
+ cache_query_cb,
+ &data);
+ g_free (query);
+
+ g_main_loop_run (data.main_loop);
+ }
+
g_main_loop_unref (data.main_loop);
g_hash_table_unref (data.values);
- g_free (query);
}
static gboolean