diff options
author | Timo Teräs <timo.teras@iki.fi> | 2023-01-31 15:14:54 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2023-01-31 15:16:04 +0200 |
commit | cf468e297b73b034eb20f867bee5206c93436754 (patch) | |
tree | 24e37582b3883d49abb6a230938541dd07886870 /src | |
parent | 609fd2187031c2401bbaa303b3cb877ab29eb44c (diff) | |
download | apk-tools-cf468e297b73b034eb20f867bee5206c93436754.tar.gz apk-tools-cf468e297b73b034eb20f867bee5206c93436754.tar.bz2 apk-tools-cf468e297b73b034eb20f867bee5206c93436754.tar.xz apk-tools-cf468e297b73b034eb20f867bee5206c93436754.zip |
cache: improve and document purging
Document cache clean --purge better. Add a cache purge alias for
it. And also purge installed package copies on disk installs.
fixes #10857
Diffstat (limited to 'src')
-rw-r--r-- | src/app_cache.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/app_cache.c b/src/app_cache.c index 8a3f126..ab192cd 100644 --- a/src/app_cache.c +++ b/src/app_cache.c @@ -153,7 +153,9 @@ static void cache_clean_item(struct apk_database *db, int static_cache, int dirf if (!static_cache) { if (strcmp(name, "installed") == 0) return; if (pkg) { - if ((db->ctx->flags & APK_PURGE) && pkg->ipkg == NULL) goto delete; + if (db->ctx->flags & APK_PURGE) { + if (db->permanent || !pkg->ipkg) goto delete; + } if (pkg->repos & db->local_repos & ~BIT(APK_REPOSITORY_CACHED)) goto delete; if (pkg->ipkg == NULL && !(pkg->repos & ~BIT(APK_REPOSITORY_CACHED))) goto delete; return; @@ -196,13 +198,16 @@ static int cache_main(void *ctx, struct apk_ctx *ac, struct apk_string_array *ar return -EINVAL; arg = args->item[0]; - if (strcmp(arg, "sync") == 0) + if (strcmp(arg, "sync") == 0) { actions = CACHE_CLEAN | CACHE_DOWNLOAD; - else if (strcmp(arg, "clean") == 0) + } else if (strcmp(arg, "clean") == 0) { actions = CACHE_CLEAN; - else if (strcmp(arg, "download") == 0) + } else if (strcmp(arg, "purge") == 0) { + actions = CACHE_CLEAN; + db->ctx->flags |= APK_PURGE; + } else if (strcmp(arg, "download") == 0) { actions = CACHE_DOWNLOAD; - else + } else return -EINVAL; if (!apk_db_cache_active(db)) |