[tracker] tracker-miner-fs: make removable days threshold configurable



commit b98bc0f88c14cd6d5e2e178329edef9c43d1b743
Author: Lionel Landwerlin <lionel g landwerlin linux intel com>
Date:   Thu Jan 27 10:38:13 2011 +0000

    tracker-miner-fs: make removable days threshold configurable
    
    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.
    
    Fixes GB#623666
    
    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 924e796..c6f2096 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
 
@@ -1037,16 +1031,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);
 



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