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>
This commit is contained in:
Dan McGee 2012-07-12 14:00:44 -05:00
parent cc6fb2e8a7
commit f619bc61f5

View file

@ -224,29 +224,30 @@ static int sync_cleancache(int level)
continue; continue;
} }
/* skip signature files - they are removed with their package file */ if (level <= 1) {
if(fnmatch("*.sig", ent->d_name, 0) == 0) { static const char * const glob_skips[] = {
continue; /* 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;
/* skip package database within the cache directory */ for(j = 0; j < sizeof(glob_skips) / sizeof(glob_skips[0]); j++) {
if(fnmatch("*.db*", ent->d_name, 0) == 0) { if(fnmatch(glob_skips[j], ent->d_name, 0) == 0) {
continue; delete = 0;
} break;
}
/* skip source packages within the cache directory */ }
if(fnmatch("*.src.tar*", ent->d_name, 0) == 0) { if(delete == 0) {
continue; 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;
} }
/* build the full filepath */ /* build the full filepath */