mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 16:28:50 -05:00
Offer to clean up non-package files in cache directory.
This implements FS#15142. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
2e043aae36
commit
8ebc07744a
@ -149,7 +149,7 @@ static int sync_cleancache(int level)
|
|||||||
/* this should not happen : the config parsing doesn't set any other value */
|
/* this should not happen : the config parsing doesn't set any other value */
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
printf(_("removing old packages from cache... "));
|
printf(_("removing old packages from cache...\n"));
|
||||||
|
|
||||||
dir = opendir(cachedir);
|
dir = opendir(cachedir);
|
||||||
if(dir == NULL) {
|
if(dir == NULL) {
|
||||||
@ -172,10 +172,13 @@ static int sync_cleancache(int level)
|
|||||||
/* build the full filepath */
|
/* build the full filepath */
|
||||||
snprintf(path, PATH_MAX, "%s%s", cachedir, ent->d_name);
|
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
|
* files here that aren't valid packages. we also don't need a full
|
||||||
* load of the package, just the metadata. */
|
* load of the package, just the metadata. */
|
||||||
if(alpm_pkg_load(path, 0, &localpkg) != 0 || localpkg == NULL) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
switch(config->cleanmethod) {
|
switch(config->cleanmethod) {
|
||||||
@ -212,14 +215,13 @@ static int sync_cleancache(int level)
|
|||||||
unlink(path);
|
unlink(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(_("done.\n"));
|
|
||||||
} else {
|
} else {
|
||||||
/* full cleanup */
|
/* full cleanup */
|
||||||
printf(_("Cache directory: %s\n"), cachedir);
|
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);
|
return(0);
|
||||||
}
|
}
|
||||||
printf(_("removing all packages from cache... "));
|
printf(_("removing all files from cache...\n"));
|
||||||
|
|
||||||
if(rmrf(cachedir)) {
|
if(rmrf(cachedir)) {
|
||||||
pm_fprintf(stderr, PM_LOG_ERROR, _("could not remove cache directory\n"));
|
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"));
|
pm_fprintf(stderr, PM_LOG_ERROR, _("could not create new cache directory\n"));
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
printf(_("done.\n"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
@ -772,6 +773,7 @@ int pacman_sync(alpm_list_t *targets)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret += sync_cleancache(config->op_s_clean);
|
ret += sync_cleancache(config->op_s_clean);
|
||||||
|
printf("\n");
|
||||||
ret += sync_cleandb_all();
|
ret += sync_cleandb_all();
|
||||||
|
|
||||||
if(trans_release() == -1) {
|
if(trans_release() == -1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user