[gnome-settings-daemon/mojito-cleanup: 2/3] Allow configurable types to be passed to the prune detector



commit 25034b1321b8b234396ed4fee63215cb8ca1c41a
Author: Ross Burton <ross linux intel com>
Date:   Thu Jul 9 14:56:38 2009 +0100

    Allow configurable types to be passed to the prune detector

 plugins/housekeeping/gsd-housekeeping-manager.c |   27 +++++++++++++++++-----
 1 files changed, 21 insertions(+), 6 deletions(-)
---
diff --git a/plugins/housekeeping/gsd-housekeeping-manager.c b/plugins/housekeeping/gsd-housekeeping-manager.c
index b798531..e8f474a 100644
--- a/plugins/housekeeping/gsd-housekeeping-manager.c
+++ b/plugins/housekeeping/gsd-housekeeping-manager.c
@@ -85,9 +85,13 @@ thumb_data_free (gpointer data)
         }
 }
 
+typedef enum {
+  HASH,
+  HASH_PNG
+} FileType;
 
 static GList *
-read_dir_for_purge (const char *path, GList *files)
+read_dir_for_purge (const char *path, GList *files, FileType type)
 {
         GFile           *read_path;
         GFileEnumerator *enum_dir;
@@ -105,9 +109,20 @@ read_dir_for_purge (const char *path, GList *files)
                 GFileInfo *info;
                 while ((info = g_file_enumerator_next_file (enum_dir, NULL, NULL)) != NULL) {
                         const char *name;
+                        gboolean prune = FALSE;
+
                         name = g_file_info_get_name (info);
 
-                        if (strlen (name) == 36 && strcmp (name + 32, ".png") == 0) {
+                        switch (type) {
+                        case HASH:
+                          prune = (strlen (name) == 36);
+                          break;
+                        case HASH_PNG:
+                          prune = (strlen (name) == 36 && strcmp (name + 32, ".png") == 0);
+                          break;
+                        }
+
+                        if (prune) {
                                 ThumbData *td;
                                 GFile     *entry;
                                 char      *entry_path;
@@ -197,14 +212,14 @@ purge_thumbnail_cache (void)
                                  ".thumbnails",
                                  "normal",
                                  NULL);
-        files = read_dir_for_purge (path, NULL);
+        files = read_dir_for_purge (path, NULL, HASH_PNG);
         g_free (path);
 
         path = g_build_filename (g_get_home_dir (),
                                  ".thumbnails",
                                  "large",
                                  NULL);
-        files = read_dir_for_purge (path, files);
+        files = read_dir_for_purge (path, files, HASH_PNG);
         g_free (path);
 
         path = g_build_filename (g_get_home_dir (),
@@ -212,14 +227,14 @@ purge_thumbnail_cache (void)
                                  "fail",
                                  "gnome-thumbnail-factory",
                                  NULL);
-        files = read_dir_for_purge (path, files);
+        files = read_dir_for_purge (path, files, HASH_PNG);
         g_free (path);
 
         path = g_build_filename (g_get_user_cache_dir (),
                                  "mojito",
                                  "thumbnails",
                                  NULL);
-        files = read_dir_for_purge (path, files);
+        files = read_dir_for_purge (path, files, HASH);
         g_free (path);
 
         g_get_current_time (&current_time);



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