Commit dc5c436c authored by Timo Teräs's avatar Timo Teräs
Browse files

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.
parent b551c3b0
......@@ -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)
snprintf(path, sizeof(path), "%s-%s.apk",
pkg->name->name, pkg->version);
delete = strcmp(&de->d_name[sizeof(csum_t)*2+1],
} 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))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment