[tracker/tracker-0.8] TrackerMinerFS: Fix mtime cache for crawl directories themselves.
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.8] TrackerMinerFS: Fix mtime cache for crawl directories themselves.
- Date: Thu, 20 May 2010 15:31:19 +0000 (UTC)
commit 0a0289555939b12809b262d86cc6c3ab043f6b0d
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu May 20 14:20:40 2010 +0200
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.
src/libtracker-miner/tracker-miner-fs.c | 50 ++++++++++++++++++++++++++++++-
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 6bf2a0c..3986a1b 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]