From 813accaeed8352a36a9e58be87b07b020548af09 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Wed, 8 Jul 2009 14:00:25 +0200 Subject: [PATCH 2/2] Offer to clean up non-package files in cache directory. This implements FS#15142. Signed-off-by: Xavier Chantry --- src/pacman/sync.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2e57b01..9a07a5e 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -148,7 +148,7 @@ static int sync_cleancache(int level) /* this should not happen : the config parsing doesn't set any other value */ return(1); } - printf(_("removing old packages from cache... ")); + printf(_("removing old packages from cache...\n")); dir = opendir(cachedir); if(dir == NULL) { @@ -171,10 +171,13 @@ static int sync_cleancache(int level) /* build the full filepath */ snprintf(path, PATH_MAX, "%s%s", cachedir, ent->d_name); - /* attempt to load the package, skip file on failures as we may have + /* attempt to load the package, prompt removal on failures as we may have * files here that aren't valid packages. we also don't need a full * load of the package, just the metadata. */ if(alpm_pkg_load(path, 0, &localpkg) != 0 || localpkg == NULL) { + if(yesno(_("File %s does not seem to be a valid package, remove it?"), path)) { + unlink(path); + } continue; } switch(config->cleanmethod) { @@ -211,14 +214,13 @@ static int sync_cleancache(int level) unlink(path); } } - printf(_("done.\n")); } else { /* full cleanup */ printf(_("Cache directory: %s\n"), cachedir); if(!noyes(_("Do you want to remove ALL packages from cache?"))) { return(0); } - printf(_("removing all packages from cache... ")); + printf(_("removing all packages from cache...\n")); if(rmrf(cachedir)) { pm_fprintf(stderr, PM_LOG_ERROR, _("could not remove cache directory\n")); @@ -229,7 +231,6 @@ static int sync_cleancache(int level) pm_fprintf(stderr, PM_LOG_ERROR, _("could not create new cache directory\n")); return(1); } - printf(_("done.\n")); } return(0); @@ -771,6 +772,7 @@ int pacman_sync(alpm_list_t *targets) } ret += sync_cleancache(config->op_s_clean); + printf("\n"); ret += sync_cleandb_all(); if(trans_release() == -1) { -- 1.6.3.3