diff options
author | Dan McGee <dan@archlinux.org> | 2012-07-12 21:00:44 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2012-08-01 16:14:40 +0200 |
commit | f619bc61f562d0dd08c502787347b31601f89be8 (patch) | |
tree | fafd52913d3673a1131a592a364ebc24cb9e5b64 /src | |
parent | cc6fb2e8a78e6d0ca9bfc778298b1dc095af7db4 (diff) | |
download | pacman-f619bc61f562d0dd08c502787347b31601f89be8.tar.gz pacman-f619bc61f562d0dd08c502787347b31601f89be8.tar.xz |
Clean up exclusion list in sync cache cleanup
Make an array out of our various glob skip patterns and loop through
them looking for items to skip. Additionally, when doing a full clean,
delete all objects rather than respect this skip list.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/sync.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 0b9e790f..713d0864 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -224,29 +224,30 @@ static int sync_cleancache(int level) continue; } - /* skip signature files - they are removed with their package file */ - if(fnmatch("*.sig", ent->d_name, 0) == 0) { - continue; - } - - /* skip package database within the cache directory */ - if(fnmatch("*.db*", ent->d_name, 0) == 0) { - continue; - } - - /* skip source packages within the cache directory */ - if(fnmatch("*.src.tar*", ent->d_name, 0) == 0) { - continue; - } - - /* skip package deltas, we aren't smart enough to clean these yet */ - if(fnmatch("*.delta", ent->d_name, 0) == 0) { - continue; - } - - /* skip any partial downloads */ - if(fnmatch("*.part", ent->d_name, 0) == 0) { - continue; + if (level <= 1) { + static const char * const glob_skips[] = { + /* skip signature files - they are removed with their package file */ + "*.sig", + /* skip package database within the cache directory */ + "*.db*", + /* skip source packages within the cache directory */ + "*.src.tar.*", + /* skip package deltas, we aren't smart enough to clean these yet */ + "*.delta", + /* skip any partial downloads */ + "*.part" + }; + size_t j; + + for(j = 0; j < sizeof(glob_skips) / sizeof(glob_skips[0]); j++) { + if(fnmatch(glob_skips[j], ent->d_name, 0) == 0) { + delete = 0; + break; + } + } + if(delete == 0) { + continue; + } } /* build the full filepath */ |