summaryrefslogtreecommitdiff
path: root/src/app_extract.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2021-07-26 21:08:09 +0300
committerTimo Teräs <timo.teras@iki.fi>2021-07-26 21:08:09 +0300
commit2d4e88aeb1690220ce57420e8d1d9de327ae901d (patch)
treee2340a8fa80745221265d820ef21379d7f972667 /src/app_extract.c
parentca1d975e5eae662cfde085338e2e29f8e6fcf64b (diff)
downloadapk-tools-2d4e88aeb1690220ce57420e8d1d9de327ae901d.tar.gz
apk-tools-2d4e88aeb1690220ce57420e8d1d9de327ae901d.tar.bz2
apk-tools-2d4e88aeb1690220ce57420e8d1d9de327ae901d.tar.xz
apk-tools-2d4e88aeb1690220ce57420e8d1d9de327ae901d.zip
extract: fix handling of error of regular file extraction
fix the error checking, allow --force-overwrite to work and do not delete existing file in case of error
Diffstat (limited to 'src/app_extract.c')
-rw-r--r--src/app_extract.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/app_extract.c b/src/app_extract.c
index 662fb81..89f3f5c 100644
--- a/src/app_extract.c
+++ b/src/app_extract.c
@@ -215,6 +215,7 @@ static int apk_extract_file(struct extract_ctx *ctx, off_t sz, struct apk_istrea
r = apk_archive_entry_extract(
ctx->root_fd, &fi, 0, 0, is, 0, 0, &dctx,
ctx->extract_flags, out);
+ if (r < 0) return r;
}
apk_digest_ctx_final(&dctx, &d);
apk_digest_ctx_free(&dctx);
@@ -344,7 +345,7 @@ static int extract_main(void *pctx, struct apk_ctx *ac, struct apk_string_array
int r = 0;
ctx->ac = ac;
- ctx->extract_flags |= APK_EXTRACTF_NO_OVERWRITE;
+ if (!(ac->force & APK_FORCE_OVERWRITE)) ctx->extract_flags |= APK_EXTRACTF_NO_OVERWRITE;
if (!ctx->destination) ctx->destination = ".";
ctx->root_fd = openat(AT_FDCWD, ctx->destination, O_RDONLY);
if (ctx->root_fd < 0) {