[Tracker] [PATCH 2/2] miner-fs: make removable days threshold configurable



From: Lionel Landwerlin <lionel g landwerlin linux intel com>

Data from removable devices is deleted after 3 days whether the device
hasn't been mounted within that time. This patch makes this delay
configurable.

Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>
---
 src/miners/fs/tracker-config.c      |    8 ++++----
 src/miners/fs/tracker-config.h      |    2 +-
 src/miners/fs/tracker-miner-files.c |   16 +++++++---------
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/miners/fs/tracker-config.c b/src/miners/fs/tracker-config.c
index bfcf600..1ccc15c 100644
--- a/src/miners/fs/tracker-config.c
+++ b/src/miners/fs/tracker-config.c
@@ -153,7 +153,7 @@ static ObjectToKeyFile conversions[] = {
        { G_TYPE_POINTER, "ignored-directories",              GROUP_INDEXING, "IgnoredDirectories"        },
        { G_TYPE_POINTER, "ignored-directories-with-content", GROUP_INDEXING, "IgnoredDirectoriesWithContent" 
},
        { G_TYPE_POINTER, "ignored-files",                    GROUP_INDEXING, "IgnoredFiles"              },
-       { G_TYPE_INT,     "crawling-interval",                GROUP_INDEXING, "CrawlingInterval"          }
+       { G_TYPE_INT,     "crawling-interval",                GROUP_INDEXING, "CrawlingInterval"          },
        { G_TYPE_INT,     "removable-days-threshold",         GROUP_INDEXING, "RemovableDaysThreshold"    }
 };
 
@@ -1259,7 +1259,7 @@ tracker_config_get_crawling_interval (TrackerConfig *config)
 }
 
 gint
-tracker_config_get_removable_day_threshold (TrackerConfig *config)
+tracker_config_get_removable_days_threshold (TrackerConfig *config)
 {
        TrackerConfigPrivate *priv;
 
@@ -1667,8 +1667,8 @@ tracker_config_set_crawling_interval (TrackerConfig *config,
 }
 
 void
-tracker_config_set_crawling_interval (TrackerConfig *config,
-                                      gint           value)
+tracker_config_set_removable_days_threshold (TrackerConfig *config,
+                                             gint           value)
 {
        TrackerConfigPrivate *priv;
 
diff --git a/src/miners/fs/tracker-config.h b/src/miners/fs/tracker-config.h
index cc48746..5327c5c 100644
--- a/src/miners/fs/tracker-config.h
+++ b/src/miners/fs/tracker-config.h
@@ -103,7 +103,7 @@ void           tracker_config_set_ignored_files                    (TrackerConfi
                                                                     GSList        *files);
 void           tracker_config_set_crawling_interval                (TrackerConfig *config,
                                                                     gint           interval);
-gint           tracker_config_set_removable_days_threshold         (TrackerConfig *config,
+void           tracker_config_set_removable_days_threshold         (TrackerConfig *config,
                                                                     gint           value);
 
 /*
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 8fc903e..f44b56f 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -57,12 +57,6 @@
 #define DISK_SPACE_CHECK_FREQUENCY 10
 #define SECONDS_PER_DAY 86400
 
-/* If any removable device was not mounted again before the given
- * number of days threshold, it will be removed from the store
- * TODO: Make this value configurable in tracker-miner-fs.cfg
- */
-#define N_DAYS_THRESHOLD 3
-
 /* Default DBus timeout to be used in requests to extractor (milliseconds) */
 #define EXTRACTOR_DBUS_TIMEOUT 60000
 
@@ -1032,16 +1026,20 @@ init_mount_points (TrackerMinerFiles *miner_files)
 static gboolean
 cleanup_stale_removable_volumes_cb (gpointer user_data)
 {
+        TrackerMinerFiles *miner = TRACKER_MINER_FILES (user_data);
+        gint n_days_threshold = tracker_config_get_removable_days_threshold (miner->private->config);
        time_t n_days_ago;
        gchar *n_days_ago_as_string;
 
-       n_days_ago = (time (NULL) - (SECONDS_PER_DAY * N_DAYS_THRESHOLD));
+        if (n_days_threshold == 0)
+                return TRUE;
+
+       n_days_ago = (time (NULL) - (SECONDS_PER_DAY * n_days_threshold));
        n_days_ago_as_string = tracker_date_to_string (n_days_ago);
 
        g_message ("Running stale volumes check...");
 
-       miner_files_in_removable_media_remove_by_date (TRACKER_MINER_FILES (user_data),
-                                                      n_days_ago_as_string);
+       miner_files_in_removable_media_remove_by_date (miner, n_days_ago_as_string);
 
        g_free (n_days_ago_as_string);
 
-- 
1.7.2.3




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