[tracker/rss-enclosures] tracker-miner-fs: during startup, remove resources based on removable/optical config
- From: Roberto Guido <rguido src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/rss-enclosures] tracker-miner-fs: during startup, remove resources based on removable/optical config
- Date: Sat, 26 Jun 2010 23:21:48 +0000 (UTC)
commit 82f831dbae3957ec588b0fd355e8bc4183456798
Author: Aleksander Morgado <aleksander lanedo com>
Date: Thu Jun 17 09:56:25 2010 +0200
tracker-miner-fs: during startup, remove resources based on removable/optical config
* If IndexRemovableMedia=false at startup, delete all resources in the store
where the nie:dataSource of the resource is a removable Volume.
* If IndexOpticalMedia=false at startup, delete all resources in the store
where the nie:dataSource of the resource is an optical Volume.
src/miners/fs/tracker-miner-files.c | 68 +++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 1a8b2b5..a2fc501 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -175,6 +175,9 @@ static void miner_finished_cb (TrackerMinerFS *fs,
guint total_files_ignored,
gpointer user_data);
+static gboolean miner_files_remove_by_type (TrackerMinerFiles *miner,
+ TrackerStorageType type);
+
G_DEFINE_TYPE (TrackerMinerFiles, tracker_miner_files, TRACKER_TYPE_MINER_FS)
static void
@@ -486,10 +489,16 @@ miner_files_constructed (GObject *object)
if (!index_removable_devices) {
g_message (" Removable devices are disabled in the config");
+
+ /* Make sure we don't have any resource in a volume of the given type */
+ miner_files_remove_by_type (mf, TRACKER_STORAGE_REMOVABLE);
}
if (!index_optical_discs) {
g_message (" Optical discs are disabled in the config");
+
+ /* Make sure we don't have any resource in a volume of the given type */
+ miner_files_remove_by_type (mf, TRACKER_STORAGE_REMOVABLE | TRACKER_STORAGE_OPTICAL);
}
for (m = mounts; m; m = m->next) {
@@ -2169,3 +2178,62 @@ tracker_miner_files_monitor_directory (GFile *file,
*/
return TRUE;
}
+
+static void
+remove_by_type_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GError *error = NULL;
+
+ tracker_miner_execute_update_finish (TRACKER_MINER (object), result, &error);
+
+ if (error) {
+ g_critical ("Could not remove by type: %s", error->message);
+ g_error_free (error);
+ }
+}
+
+static gboolean
+miner_files_remove_by_type (TrackerMinerFiles *miner,
+ TrackerStorageType type)
+{
+ gboolean removable;
+ gboolean optical;
+
+ removable = type & TRACKER_STORAGE_REMOVABLE ? TRUE : FALSE;
+ optical = type & TRACKER_STORAGE_OPTICAL ? TRUE : FALSE;
+
+ /* Only remove if any of the flags was TRUE */
+ if (removable || optical) {
+ GString *queries;
+
+ queries = g_string_new ("");
+
+ /* Delete all resources where nie:dataSource is a volume
+ * of the given type */
+ g_string_append_printf (queries,
+ "DELETE { "
+ " ?f a rdfs:Resource "
+ "} WHERE { "
+ " ?v a tracker:Volume ; "
+ " tracker:isRemovable %s ; "
+ " tracker:isOptical %s . "
+ " ?f nie:dataSource ?v "
+ "}",
+ removable ? "true" : "false",
+ optical ? "true" : "false");
+
+ tracker_miner_execute_batch_update (TRACKER_MINER (miner),
+ queries->str,
+ NULL,
+ remove_by_type_cb,
+ NULL);
+
+ g_string_free (queries, TRUE);
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]