aboutsummaryrefslogtreecommitdiffstats
path: root/src/cache.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2009-07-07 09:40:59 +0300
committerTimo Teras <timo.teras@iki.fi>2009-07-07 09:40:59 +0300
commitdc5c436c5a5ec183854923ce2fef955e8118564e (patch)
tree4dd16a490f25b77d50d460460900b549565aec5a /src/cache.c
parentb551c3b0814d5baff46a7705758e773684255d29 (diff)
downloadapk-tools-dc5c436c5a5ec183854923ce2fef955e8118564e.tar.gz
apk-tools-dc5c436c5a5ec183854923ce2fef955e8118564e.tar.bz2
apk-tools-dc5c436c5a5ec183854923ce2fef955e8118564e.tar.xz
cache: delete also wget temporary files
check for the full filename to match an expected pattern or delete it (so we delete files with .new, .new.backup, etc.). final part of remote package caching: fixes #49.
Diffstat (limited to 'src/cache.c')
-rw-r--r--src/cache.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/cache.c b/src/cache.c
index 68175c3..2e9dda7 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -67,6 +67,7 @@ static int cache_clean(struct apk_database *db)
{
DIR *dir;
struct dirent *de;
+ struct apk_package *pkg;
char path[256];
int delete, i;
csum_t csum;
@@ -102,13 +103,20 @@ static int cache_clean(struct apk_database *db)
delete = (i >= db->num_repos);
} else {
/* Package - search for it */
- delete = (apk_db_get_pkg(db, csum) == NULL);
+ pkg = apk_db_get_pkg(db, csum);
+ if (pkg == NULL)
+ break;
+
+ snprintf(path, sizeof(path), "%s-%s.apk",
+ pkg->name->name, pkg->version);
+ delete = strcmp(&de->d_name[sizeof(csum_t)*2+1],
+ path);
}
} while (0);
if (delete) {
if (apk_verbosity >= 2)
- apk_message("Deleting %s", de->d_name);
+ apk_message("deleting %s", de->d_name);
if (!(apk_flags & APK_SIMULATE))
unlink(de->d_name);
}