mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-10 05:18:16 -05:00
pacman/sync.c : improve the sync db cleanup feature.
This feature (introduced by b118ce55bd
as a
part of -Sc) could actually be helpful in the 3.0 -> 3.1 transition, because
all sync dbs will be left in /var/lib/pacman/, while the updated ones will
go to /var/lib/pacman/sync/.
So it'll now clean everything in /var/lib/pacman/, and only the unused
databases in /var/lib/pacman/sync/ (with the exception of local/ and sync/
in both cases).
Note: This feature is undocumented. I wonder if moving it to another option,
something like -S --dbclean, wouldn't help for documenting it.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
43eacf2852
commit
c49b2a00d6
@ -43,7 +43,9 @@
|
|||||||
|
|
||||||
extern pmdb_t *db_local;
|
extern pmdb_t *db_local;
|
||||||
|
|
||||||
static int sync_cleandb(const char *dbpath) {
|
/* if keep_used != 0, then the dirnames which match an used syncdb
|
||||||
|
* will be kept */
|
||||||
|
static int sync_cleandb(const char *dbpath, int keep_used) {
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
|
|
||||||
@ -68,12 +70,13 @@ static int sync_cleandb(const char *dbpath) {
|
|||||||
if(!strcmp(dname, "sync") || !strcmp(dname, "local")) {
|
if(!strcmp(dname, "sync") || !strcmp(dname, "local")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
syncdbs = alpm_option_get_syncdbs();
|
if(keep_used) {
|
||||||
for(i = syncdbs; i && !found; i = alpm_list_next(i)) {
|
syncdbs = alpm_option_get_syncdbs();
|
||||||
pmdb_t *db = alpm_list_getdata(i);
|
for(i = syncdbs; i && !found; i = alpm_list_next(i)) {
|
||||||
found = !strcmp(dname, alpm_db_get_name(db));
|
pmdb_t *db = alpm_list_getdata(i);
|
||||||
|
found = !strcmp(dname, alpm_db_get_name(db));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have a directory that doesn't match any syncdb.
|
/* We have a directory that doesn't match any syncdb.
|
||||||
* Ask the user if he wants to remove it. */
|
* Ask the user if he wants to remove it. */
|
||||||
if(!found) {
|
if(!found) {
|
||||||
@ -102,12 +105,13 @@ static int sync_cleandb_all(void) {
|
|||||||
if(!yesno(_("Do you want to remove unused repositories? [Y/n] "))) {
|
if(!yesno(_("Do you want to remove unused repositories? [Y/n] "))) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
/* The sync dbs were previously put in dbpath, but are now in dbpath/sync,
|
/* The sync dbs were previously put in dbpath/, but are now in dbpath/sync/,
|
||||||
* so we will clean both directories */
|
* so we will clean everything in dbpath/ (except dbpath/local/ and dbpath/sync/,
|
||||||
sync_cleandb(dbpath);
|
* and only the unused sync dbs in dbpath/sync/ */
|
||||||
|
sync_cleandb(dbpath, 0);
|
||||||
|
|
||||||
sprintf(newdbpath, "%s%s", dbpath, "sync/");
|
sprintf(newdbpath, "%s%s", dbpath, "sync/");
|
||||||
sync_cleandb(newdbpath);
|
sync_cleandb(newdbpath, 1);
|
||||||
|
|
||||||
printf(_("Database directory cleaned up\n"));
|
printf(_("Database directory cleaned up\n"));
|
||||||
return(0);
|
return(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user