[tracker/miner-fs-initial-sleep] tracker-miner-fs: Use the initial-sleep configuration in the files miner
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/miner-fs-initial-sleep] tracker-miner-fs: Use the initial-sleep configuration in the files miner
- Date: Wed, 23 Mar 2011 18:31:35 +0000 (UTC)
commit c4ef081b46d8e9a708219cb58c2e1cc37ed83154
Author: Aleksander Morgado <aleksander lanedo com>
Date: Wed Mar 23 19:29:03 2011 +0100
tracker-miner-fs: Use the initial-sleep configuration in the files miner
Fixes GB#644997
src/miners/fs/tracker-miner-files.c | 52 +++++++++++++++++++++++++++++++++++
1 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index cd16247..81be5a5 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -116,6 +116,9 @@ struct TrackerMinerFilesPrivate {
guint low_battery_pause_cookie;
+ guint initial_sleep_id;
+ guint initial_sleep_cookie;
+
#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
TrackerPower *power;
#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
@@ -185,6 +188,7 @@ static void index_on_battery_cb (GObject *object,
gpointer user_data);
#endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
static void init_mount_points (TrackerMinerFiles *miner);
+static void init_initial_sleep (TrackerMinerFiles *miner);
static void init_stale_volume_removal (TrackerMinerFiles *miner);
static void disk_space_check_start (TrackerMinerFiles *mf);
static void disk_space_check_stop (TrackerMinerFiles *mf);
@@ -574,6 +578,8 @@ miner_files_initable_init (GInitable *initable,
disk_space_check_start (mf);
+ init_initial_sleep (mf);
+
return TRUE;
}
@@ -672,6 +678,11 @@ miner_files_finalize (GObject *object)
priv->stale_volumes_check_id = 0;
}
+ if (priv->initial_sleep_id) {
+ g_source_remove (priv->initial_sleep_id);
+ priv->initial_sleep_id = 0;
+ }
+
G_OBJECT_CLASS (tracker_miner_files_parent_class)->finalize (object);
}
@@ -1261,6 +1272,47 @@ mount_point_added_cb (TrackerStorage *storage,
g_free (urn);
}
+static gboolean
+initial_sleep_finished_cb (gpointer data)
+{
+ TrackerMinerFiles *miner = TRACKER_MINER_FILES (data);
+
+ if (miner->private->initial_sleep_cookie != 0) {
+ g_debug ("Finished initial sleep");
+ tracker_miner_resume (TRACKER_MINER (miner),
+ miner->private->initial_sleep_cookie,
+ NULL);
+ miner->private->initial_sleep_cookie = 0;
+ }
+
+ return FALSE;
+}
+
+static void
+init_initial_sleep (TrackerMinerFiles *miner)
+{
+ gint initial_sleep;
+
+ initial_sleep = tracker_config_get_initial_sleep (miner->private->config);
+
+ g_debug ("Initially sleeping for '%d' seconds",
+ initial_sleep);
+
+ if (initial_sleep > 0) {
+ /* Pause this miner */
+ miner->private->initial_sleep_cookie =
+ tracker_miner_pause (TRACKER_MINER (miner),
+ _("Initial sleep"),
+ NULL);
+
+ /* Schedule a timeout to un-pause the miner after the initial sleep */
+ miner->private->initial_sleep_id =
+ g_timeout_add_seconds (initial_sleep,
+ initial_sleep_finished_cb,
+ miner);
+ }
+}
+
#if defined(HAVE_UPOWER) || defined(HAVE_HAL)
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]