From 208263f33c3d06ef97c5b1de12bd760426ead9ad Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Thu, 30 Aug 2012 15:53:28 +0200 Subject: [PATCH] Remove commented out code. --- src/cache_maint.c | 173 ---------------------------------------------- 1 file changed, 173 deletions(-) diff --git a/src/cache_maint.c b/src/cache_maint.c index 1bb5b876..429f9d4e 100644 --- a/src/cache_maint.c +++ b/src/cache_maint.c @@ -49,25 +49,6 @@ struct _CMData *------------------------------------------------------------------- */ -#if 0 -static gint extension_truncate(gchar *path, const gchar *ext) -{ - gint l; - gint el; - - if (!path || !ext) return FALSE; - - l = strlen(path); - el = strlen(ext); - - if (l < el || strcmp(path + (l - el), ext) != 0) return FALSE; - - path[l - el] = '\0'; - - return TRUE; -} -#endif - static gchar *extension_find_dot(gchar *path) { gchar *dot = NULL; @@ -348,160 +329,6 @@ void cache_maintain_home(gboolean metadata, gboolean clear, GtkWidget *parent) cm->idle_id = g_idle_add(cache_maintain_home_cb, cm); } -#if 0 -/* This checks all files in ~/GQ_RC_DIR/thumbnails and - * removes them if thay have no source counterpart. - * (this assumes all cache files have an extension of 4 chars including '.') - */ -gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear) -{ - gchar *base; - gint base_length; - GList *dlist = NULL; - FileData *dir_fd; - GList *flist = NULL; - gboolean still_have_a_file = FALSE; - - DEBUG_1("maintainance check: %s", dir); - - base_length = strlen(homedir()) + strlen("/") + strlen(GQ_CACHE_RC_THUMB); - base = g_strconcat(homedir(), "/", GQ_CACHE_RC_THUMB, dir, NULL); - dir_fd = file_data_new_dir(base); - g_free(base); - - if (filelist_read(dir_fd, &flist, &dlist)) - { - GList *work; - - work = dlist; - while (work) - { - FileData *fd = work->data; - if (recursive && strlen(fd->path) > base_length && - !cache_maintain_home_dir(fd->path + base_length, recursive, clear)) - { - DEBUG_1("Deleting thumb dir: %s", fd->path); - if (!rmdir_utf8(fd->path)) - { - log_printf("Unable to delete dir: %s\n", fd->path); - } - } - else - { - still_have_a_file = TRUE; - } - work = work->next; - } - - work = flist; - while (work) - { - FileData *fd = work->data; - gchar *path = g_strdup(fd->path); - gchar *dot; - - dot = extension_find_dot(path); - - if (dot) *dot = '\0'; - if (clear || - (strlen(path) > base_length && !isfile(path + base_length)) ) - { - if (dot) *dot = '.'; - if (!unlink_file(path)) log_printf("failed to delete:%s\n", path); - } - else - { - still_have_a_file = TRUE; - } - g_free(path); - - work = work->next; - } - } - - filelist_free(dlist); - filelist_free(flist); - file_data_unref(dir_fd); - - return still_have_a_file; -} - -/* This checks relative caches in dir/.thumbnails and - * removes them if they have no source counterpart. - */ -gint cache_maintain_dir(FileData *dir_fd, gint recursive, gint clear) -{ - GList *list = NULL; - gchar *cachedir; - FileData *cachedir_fd; - gboolean still_have_a_file = FALSE; - GList *work; - - cachedir = g_build_filename(dir, GQ_CACHE_LOCAL_THUMB, NULL); - cachedir_fd = file_data_new_dir(cachedir); - g_free(cachedir); - - filelist_read(cachedir_fd, &list, NULL); - work = list; - - while (work) - { - FileData *fd; - gchar *source; - - fd = work->data; - work = work->next; - - source = g_build_filename(dir->path, fd->name, NULL); - - if (clear || - extension_truncate(source, GQ_CACHE_EXT_THUMB) || - extension_truncate(source, GQ_CACHE_EXT_SIM)) - { - if (!clear && isfile(source)) - { - still_have_a_file = TRUE; - } - else - { - if (!unlink_file(fd->path)) - { - DEBUG_1("Failed to remove cache file %s", fd->path); - still_have_a_file = TRUE; - } - } - } - else - { - still_have_a_file = TRUE; - } - g_free(source); - } - - filelist_free(list); - file_data_unref(cachedir_fd); - - if (recursive) - { - list = NULL; - - filelist_read(dir_fd, NULL, &list); - work = list; - while (work) - { - FileData *fd = work->data; - work = work->next; - - still_have_a_file |= cache_maintain_dir(fd->path, recursive, clear); - } - - filelist_free(list); - } - - return still_have_a_file; -} -#endif - static void cache_file_move(const gchar *src, const gchar *dest) { if (!dest || !src || !isfile(src)) return; -- 2.20.1