From 8ebc07744ac58ed1e42af3a52d998587fca85f8b Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Wed, 8 Jul 2009 14:00:25 +0200 Subject: Offer to clean up non-package files in cache directory. This implements FS#15142. Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- src/pacman/sync.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/pacman') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index e644b225..cb0b8b19 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -149,7 +149,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) { @@ -172,10 +172,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) { @@ -212,14 +215,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?"))) { + if(!noyes(_("Do you want to remove ALL files from cache?"))) { return(0); } - printf(_("removing all packages from cache... ")); + printf(_("removing all files from cache...\n")); if(rmrf(cachedir)) { pm_fprintf(stderr, PM_LOG_ERROR, _("could not remove cache directory\n")); @@ -230,7 +232,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); @@ -772,6 +773,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) { -- cgit v1.2.3-70-g09d2