[tracker/sam/index-mount-points: 10/11] libtracker-miner: Add ownership tracking, and tracker_miner_fs_ignore()



commit 0fc3cfd620362137207608203972289c1e1e3083
Author: Sam Thursfield <sam afuera me uk>
Date:   Wed Aug 12 15:02:24 2015 +0100

    libtracker-miner: Add ownership tracking, and tracker_miner_fs_ignore()
    
    This lets us add external (D-Bus) functions to control the internal
    TrackerIndexingTree, and thus control from outside the miner what is
    being indexed and what is not. Previously the only way to control that
    was via GSettings.
    
    The tracker_miner_fs_directory_add() functions now take an 'owner'
    parameter so they can keep track of who is interested in each configured
    indexing root. The tracker_miner_fs_ignore() function lets a given owner
    that previously expressed interest in an indexing root now say that they
    are not interested. If that indexing root has no 'owners' left, it is
    deleted from the TrackerIndexingTree, which cancels any running indexing
    tasks and removes any monitors.

 examples/libtracker-miner/tracker-main.c |    2 +-
 src/libtracker-miner/tracker-miner-fs.c  |   57 ++++++++++++++++++++++++-----
 src/libtracker-miner/tracker-miner-fs.h  |   16 ++++++--
 3 files changed, 60 insertions(+), 15 deletions(-)
---
diff --git a/examples/libtracker-miner/tracker-main.c b/examples/libtracker-miner/tracker-main.c
index a6699c7..07568c7 100644
--- a/examples/libtracker-miner/tracker-main.c
+++ b/examples/libtracker-miner/tracker-main.c
@@ -183,7 +183,7 @@ add_directory_path (TrackerMinerFS *fs,
        GFile *file;
 
        file = g_file_new_for_path (path);
-       tracker_miner_fs_directory_add (fs, file, recurse);
+       tracker_miner_fs_directory_add (fs, file, recurse, "tracker-miner-example");
        g_object_unref (file);
 }
 
diff --git a/src/libtracker-miner/tracker-miner-fs.c b/src/libtracker-miner/tracker-miner-fs.c
index 5ac192a..33e0a55 100644
--- a/src/libtracker-miner/tracker-miner-fs.c
+++ b/src/libtracker-miner/tracker-miner-fs.c
@@ -3210,6 +3210,7 @@ file_equal_or_descendant (GFile *file,
  * @fs: a #TrackerMinerFS
  * @file: #GFile for the directory to inspect
  * @recurse: whether the directory should be inspected recursively
+ * @owner: a short string identifying who 'owns' this request
  *
  * Tells the filesystem miner to inspect a directory.
  *
@@ -3218,7 +3219,8 @@ file_equal_or_descendant (GFile *file,
 void
 tracker_miner_fs_directory_add (TrackerMinerFS *fs,
                                 GFile          *file,
-                                gboolean        recurse)
+                                gboolean        recurse,
+                                const gchar    *owner)
 {
        TrackerDirectoryFlags flags = TRACKER_DIRECTORY_FLAG_NONE;
 
@@ -3240,7 +3242,7 @@ tracker_miner_fs_directory_add (TrackerMinerFS *fs,
        tracker_indexing_tree_add (fs->priv->indexing_tree,
                                   file,
                                   flags,
-                                  "FIXME: owner");
+                                  owner);
 }
 
 static void
@@ -3270,13 +3272,16 @@ set_up_mount_point_cb (GObject      *source,
  * @mount: #GMount for the mount-point to inspect
  *
  * Tells the filesystem miner to inspect a mount. It ignores the values
- * of the index-removable-devices and index-optical-discs gsettings keys.
+ * of the index-removable-devices and index-optical-discs gsettings keys, so
+ * that when automatic indexing of removal devices is disabled, applications
+ * can still do 'on demand' indexing of such devices.
  *
  * Since: 0.16
  **/
 void
 tracker_miner_fs_mount_add (TrackerMinerFS *fs,
-                            GMount         *mount)
+                            GMount         *mount,
+                            const gchar    *owner)
 {
        GFile *mount_point;
        gchar *mount_uri;
@@ -3350,7 +3355,7 @@ tracker_miner_fs_mount_add (TrackerMinerFS *fs,
 
        g_string_free (queries, TRUE);
 
-       tracker_miner_fs_directory_add (fs, mount_point, TRUE);
+       tracker_miner_fs_directory_add (fs, mount_point, TRUE, owner);
 
        g_object_unref (mount_point);
 }
@@ -3744,6 +3749,7 @@ tracker_miner_fs_check_file (TrackerMinerFS *fs,
  * @file: #GFile for the directory to check
  * @priority: the priority of the check task
  * @check_parents: whether to check parents and eligibility or not
+ * @owner: a short string identifying who 'owns' this request
  *
  * Tells the filesystem miner to check and index a directory at
  * a given priority, this file must be part of the usual crawling
@@ -3755,7 +3761,8 @@ void
 tracker_miner_fs_check_directory_with_priority (TrackerMinerFS *fs,
                                                 GFile          *file,
                                                 gint            priority,
-                                                gboolean        check_parents)
+                                                gboolean        check_parents,
+                                                const gchar    *owner)
 {
        gboolean should_process = TRUE;
        gchar *uri;
@@ -3792,7 +3799,7 @@ tracker_miner_fs_check_directory_with_priority (TrackerMinerFS *fs,
                        flags |= TRACKER_DIRECTORY_FLAG_PRIORITY;
 
                tracker_indexing_tree_add (fs->priv->indexing_tree,
-                                          file, flags, "FIXME: owner");
+                                          file, flags, owner);
        }
 
        g_free (uri);
@@ -3803,6 +3810,7 @@ tracker_miner_fs_check_directory_with_priority (TrackerMinerFS *fs,
  * @fs: a #TrackerMinerFS
  * @file: #GFile for the directory to check
  * @check_parents: whether to check parents and eligibility or not
+ * @owner: a short string identifying who 'owns' this request
  *
  * Tells the filesystem miner to check and index a directory,
  * this file must be part of the usual crawling directories
@@ -3813,11 +3821,40 @@ tracker_miner_fs_check_directory_with_priority (TrackerMinerFS *fs,
 void
 tracker_miner_fs_check_directory (TrackerMinerFS *fs,
                                   GFile          *file,
-                                  gboolean        check_parents)
+                                  gboolean        check_parents,
+                                  const gchar    *owner)
 {
        tracker_miner_fs_check_directory_with_priority (fs, file,
                                                        G_PRIORITY_HIGH,
-                                                       check_parents);
+                                                       check_parents,
+                                                       owner);
+}
+
+/**
+ * tracker_miner_fs_ignore:
+ * @fs: a #TrackerMinerFS
+ * @file: #GFile for the file or directory to ignore
+ * @owner: the owner string that was given when the directory was added for indexing
+ *
+ * Tells the filesystem miner that @owner is no longer interested in @file.
+ * This can be used for files or directories added with
+ * tracker_miner_fs_check_file(), tracker_miner_fs_check_directory() or
+ * tracker_miner_fs_add_mount().
+ *
+ * The metadata for @file and its contents is *not* removed from the Tracker
+ * database. You can use tracker_miner_fs_remove() for this if you are
+ * *certain* nothing else is interested in the data.
+ *
+ * Since: 1.6
+ **/
+void
+tracker_miner_fs_ignore (TrackerMinerFS *fs,
+                         GFile          *file,
+                         const gchar    *owner)
+{
+       /* OK! You can remove 'file' from the TrackerIndexingTree ...
+        * But you also need to remove it from any QUEUES, right? */
+       tracker_indexing_tree_remove (fs->priv->indexing_tree, file, owner);
 }
 
 /**
@@ -4303,7 +4340,7 @@ tracker_miner_fs_add_directory_without_parent (TrackerMinerFS *fs,
        tracker_indexing_tree_add (fs->priv->indexing_tree,
                                   file,
                                   flags,
-                                  "FIXME: owner");
+                                  "tracker-internal-owner");
 }
 #endif
 
diff --git a/src/libtracker-miner/tracker-miner-fs.h b/src/libtracker-miner/tracker-miner-fs.h
index 8e2e07f..c954388 100644
--- a/src/libtracker-miner/tracker-miner-fs.h
+++ b/src/libtracker-miner/tracker-miner-fs.h
@@ -151,13 +151,15 @@ void                  tracker_miner_fs_add_directory_without_parent
 
 void                  tracker_miner_fs_directory_add         (TrackerMinerFS  *fs,
                                                               GFile           *file,
-                                                              gboolean         recurse);
+                                                              gboolean         recurse,
+                                                              const gchar     *owner);
 gboolean              tracker_miner_fs_directory_remove      (TrackerMinerFS  *fs,
                                                               GFile           *file);
 gboolean              tracker_miner_fs_directory_remove_full (TrackerMinerFS  *fs,
                                                               GFile           *file);
 void                  tracker_miner_fs_mount_add             (TrackerMinerFS  *fs,
-                                                              GMount          *mount);
+                                                              GMount          *mount,
+                                                              const gchar     *owner);
 void                  tracker_miner_fs_force_mtime_checking  (TrackerMinerFS  *fs,
                                                               GFile           *directory);
 
@@ -172,12 +174,18 @@ void                  tracker_miner_fs_check_file_with_priority
                                                               gboolean         check_parents);
 void                  tracker_miner_fs_check_directory       (TrackerMinerFS  *fs,
                                                               GFile           *file,
-                                                              gboolean         check_parents);
+                                                              gboolean         check_parents,
+                                                              const gchar     *owner);
 void                  tracker_miner_fs_check_directory_with_priority
                                                              (TrackerMinerFS  *fs,
                                                               GFile           *file,
                                                               gint             priority,
-                                                              gboolean         check_parents);
+                                                              gboolean         check_parents,
+                                                              const gchar     *owner);
+
+void                  tracker_miner_fs_ignore                (TrackerMinerFS  *fs,
+                                                              GFile           *file,
+                                                              const gchar     *owner);
 
 void                  tracker_miner_fs_force_recheck         (TrackerMinerFS  *fs);
 void                  tracker_miner_fs_writeback_file        (TrackerMinerFS  *fs,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]