[tracker/forced-mtime-check-per-directory: 1/5] libtracker-miner: new tracker_miner_fs_force_mtime_checking() method
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/forced-mtime-check-per-directory: 1/5] libtracker-miner: new tracker_miner_fs_force_mtime_checking() method
- Date: Thu, 8 Sep 2011 14:59:27 +0000 (UTC)
commit 231d6069e3ccd43abbd27300a89402dfe962f759
Author: Aleksander Morgado <aleksander lanedo com>
Date: Tue Sep 6 17:46:08 2011 +0200
libtracker-miner: new tracker_miner_fs_force_mtime_checking() method
This method allows specifying which directories will be forced to have mtime
checks, regardless of the global mtime checking configuration.
Fixes NB#277052.
.../libtracker-miner/libtracker-miner-sections.txt | 1 +
src/libtracker-miner/tracker-miner-fs.c | 77 +++++++++++++++++++-
src/libtracker-miner/tracker-miner-fs.h | 2 +
3 files changed, 77 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/libtracker-miner/libtracker-miner-sections.txt b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
index 4f45b74..1528c2f 100644
--- a/docs/reference/libtracker-miner/libtracker-miner-sections.txt
+++ b/docs/reference/libtracker-miner/libtracker-miner-sections.txt
@@ -84,6 +84,7 @@ tracker_miner_fs_get_initial_crawling
tracker_miner_fs_set_initial_crawling
tracker_miner_fs_get_mtime_checking
tracker_miner_fs_set_mtime_checking
+tracker_miner_fs_force_mtime_checking
tracker_miner_fs_has_items_to_process
<SUBSECTION Standard>
TRACKER_MINER_FS
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 71bbefd..850eff7 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -234,6 +234,10 @@ struct _TrackerMinerFSPrivate {
/* Files to check if no longer exist */
GHashTable *check_removed;
+ /* Config directories where we should force mtime checking, regardless of
+ * the global mtime check configuration. */
+ GList *forced_mtime_check_directories;
+
/* Status */
guint been_started : 1; /* TRUE if miner has been started */
guint been_crawled : 1; /* TRUE if initial crawling has been
@@ -389,6 +393,11 @@ static gboolean miner_fs_has_children_without_parent (TrackerMinerFS *fs,
static void task_pool_cancel_foreach (gpointer data,
gpointer user_data);
+static gboolean miner_fs_is_forced_mtime_checking_directory (TrackerMinerFS *fs,
+ GFile *directory);
+static gboolean miner_fs_should_check_mtime (TrackerMinerFS *fs,
+ GFile *file,
+ gboolean is_directory);
static GInitableIface* miner_fs_initable_parent_iface;
static guint signals[LAST_SIGNAL] = { 0, };
@@ -863,6 +872,11 @@ fs_finalize (GObject *object)
g_list_free (priv->config_directories);
}
+ if (priv->forced_mtime_check_directories) {
+ g_list_foreach (priv->forced_mtime_check_directories, (GFunc) g_object_unref, NULL);
+ g_list_free (priv->forced_mtime_check_directories);
+ }
+
tracker_priority_queue_foreach (priv->crawled_directories,
(GFunc) crawled_directory_data_free,
NULL);
@@ -4009,7 +4023,7 @@ crawler_check_file_cb (TrackerCrawler *crawler,
TrackerMinerFS *fs = user_data;
if (!fs->priv->been_crawled &&
- (!fs->priv->mtime_checking ||
+ (!miner_fs_should_check_mtime (fs, file, FALSE) ||
!fs->priv->initial_crawling)) {
return FALSE;
}
@@ -4047,7 +4061,7 @@ crawler_check_directory_cb (TrackerCrawler *crawler,
gboolean should_change_index;
if (!fs->priv->been_crawled &&
- (!fs->priv->mtime_checking ||
+ (!miner_fs_should_check_mtime (fs, file, TRUE) ||
!fs->priv->initial_crawling)) {
should_change_index = FALSE;
} else {
@@ -4111,7 +4125,8 @@ crawler_check_directory_contents_cb (TrackerCrawler *crawler,
* -First crawl has already been done OR
* -mtime_checking is TRUE.
*/
- if (fs->priv->been_crawled || fs->priv->mtime_checking) {
+ if (fs->priv->been_crawled ||
+ miner_fs_should_check_mtime (fs, parent, TRUE)) {
/* Set quark to identify item found during crawling */
g_object_set_qdata (G_OBJECT (parent),
fs->priv->quark_directory_found_crawling,
@@ -5356,6 +5371,62 @@ tracker_miner_fs_get_mtime_checking (TrackerMinerFS *fs)
return fs->priv->mtime_checking;
}
+static gboolean
+miner_fs_is_forced_mtime_checking_directory (TrackerMinerFS *fs,
+ GFile *directory)
+{
+ GList *l;
+
+ /* Ensure we don't add the same one more than once */
+ for (l = fs->priv->forced_mtime_check_directories; l; l = g_list_next (l)) {
+ if (g_file_equal (directory, G_FILE (l->data)) ||
+ g_file_has_prefix (directory, G_FILE (l->data)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
+miner_fs_should_check_mtime (TrackerMinerFS *fs,
+ GFile *file,
+ gboolean is_directory)
+{
+ if (fs->priv->mtime_checking)
+ return TRUE;
+
+ if (is_directory)
+ return miner_fs_is_forced_mtime_checking_directory (fs, file);
+
+ return FALSE;
+}
+
+/**
+ * tracker_miner_fs_force_mtime_checking:
+ * @fs: a #TrackerMinerFS
+ *
+ * Tells @fs to force mtime checking (regardless of the global mtime check
+ * configuration) on the given @directory.
+ *
+ * Since: 0.12
+ **/
+void
+tracker_miner_fs_force_mtime_checking (TrackerMinerFS *fs,
+ GFile *directory)
+{
+ gchar *uri;
+
+ if (miner_fs_is_forced_mtime_checking_directory (fs, directory))
+ return;
+
+ uri = g_file_get_uri (directory);
+ g_debug ("Will force mtime checks under directory '%s'", uri);
+ g_free (uri);
+
+ fs->priv->forced_mtime_check_directories =
+ g_list_prepend (fs->priv->forced_mtime_check_directories,
+ g_object_ref (directory));
+}
+
void
tracker_miner_fs_set_initial_crawling (TrackerMinerFS *fs,
gboolean do_initial_crawling)
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index cdaeb7d..f5f3b6b 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -165,6 +165,8 @@ gboolean tracker_miner_fs_has_items_to_process (TrackerMinerFS *fs)
void tracker_miner_fs_add_directory_without_parent (TrackerMinerFS *fs,
GFile *file);
+void tracker_miner_fs_force_mtime_checking (TrackerMinerFS *fs,
+ GFile *directory);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]