[gnome-settings-daemon/gnome-3-8] housekeeping: Optimise for "do nothing" when cleaning thumbnails



commit aa97362658422a130ca140f7933725d057cda52e
Author: Mark Ellis <mark mpellis org uk>
Date:   Mon Sep 30 14:26:00 2013 +0000

    housekeeping: Optimise for "do nothing" when cleaning thumbnails
    
    If max_age and max_size are both -1, thumbnail cleaning
    is disabled, so there is no need to scan the cache
    directories.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=625609
    https://bugs.launchpad.net/ubuntu/+source/gnome-settings-daemon/+bug/505085

 plugins/housekeeping/gsd-housekeeping-manager.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/plugins/housekeeping/gsd-housekeeping-manager.c b/plugins/housekeeping/gsd-housekeeping-manager.c
index f51d520..6e0c25d 100644
--- a/plugins/housekeeping/gsd-housekeeping-manager.c
+++ b/plugins/housekeeping/gsd-housekeeping-manager.c
@@ -225,6 +225,13 @@ purge_thumbnail_cache (GsdHousekeepingManager *manager)
 
         g_debug ("housekeeping: checking thumbnail cache size and freshness");
 
+        purge_data.max_age = g_settings_get_int (manager->priv->settings, THUMB_AGE_KEY) * 24 * 60 * 60;
+        purge_data.max_size = g_settings_get_int (manager->priv->settings, THUMB_SIZE_KEY) * 1024 * 1024;
+
+        /* if both are set to -1, we don't need to read anything */
+        if ((purge_data.max_age < 0) && (purge_data.max_size < 0))
+                return;
+
         paths = get_thumbnail_dirs ();
         files = NULL;
         for (i = 0; paths[i] != NULL; i++)
@@ -234,8 +241,6 @@ purge_thumbnail_cache (GsdHousekeepingManager *manager)
         g_get_current_time (&current_time);
 
         purge_data.now = current_time.tv_sec;
-        purge_data.max_age = g_settings_get_int (manager->priv->settings, THUMB_AGE_KEY) * 24 * 60 * 60;
-        purge_data.max_size = g_settings_get_int (manager->priv->settings, THUMB_SIZE_KEY) * 1024 * 1024;
         purge_data.total_size = 0;
 
         if (purge_data.max_age >= 0)


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