index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Chantry Xavier <shiningxc@gmail.com> | 2007-12-05 23:47:54 +0100 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-12-05 19:57:35 -0600 |
commit | c49b2a00d628c2ecb86b3908c1901ab3edee0b1a (patch) | |
tree | 29f5b204e3d39fe40e696e55d0cccba8bee21ea8 | |
parent | 43eacf2852a15828a4becff74efad04f85305a92 (diff) |
-rw-r--r-- | src/pacman/sync.c | 24 |
diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2c16382f..9cf781a9 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -43,7 +43,9 @@ 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; struct dirent *ent; @@ -68,12 +70,13 @@ static int sync_cleandb(const char *dbpath) { if(!strcmp(dname, "sync") || !strcmp(dname, "local")) { continue; } - syncdbs = alpm_option_get_syncdbs(); - for(i = syncdbs; i && !found; i = alpm_list_next(i)) { - pmdb_t *db = alpm_list_getdata(i); - found = !strcmp(dname, alpm_db_get_name(db)); + if(keep_used) { + syncdbs = alpm_option_get_syncdbs(); + for(i = syncdbs; i && !found; i = alpm_list_next(i)) { + 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. * Ask the user if he wants to remove it. */ if(!found) { @@ -102,12 +105,13 @@ static int sync_cleandb_all(void) { if(!yesno(_("Do you want to remove unused repositories? [Y/n] "))) { return(0); } - /* The sync dbs were previously put in dbpath, but are now in dbpath/sync, - * so we will clean both directories */ - sync_cleandb(dbpath); + /* The sync dbs were previously put in dbpath/, but are now in dbpath/sync/, + * so we will clean everything in dbpath/ (except dbpath/local/ and dbpath/sync/, + * and only the unused sync dbs in dbpath/sync/ */ + sync_cleandb(dbpath, 0); sprintf(newdbpath, "%s%s", dbpath, "sync/"); - sync_cleandb(newdbpath); + sync_cleandb(newdbpath, 1); printf(_("Database directory cleaned up\n")); return(0); |