From f446f2253de6d013e3dfaa7fcc3e9b6c5fbe520e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Tue, 3 Aug 2021 21:47:19 +0300 Subject: [PATCH] extract: fix --force-overwrite Directories are handled specially in package installation code, but extract applet uses also apk_extract_file() to create directories. These should not be unlinked as that fails with unexpected error code terminating the extraction. --- src/extract.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extract.c b/src/extract.c index c5169be..1e092c5 100644 --- a/src/extract.c +++ b/src/extract.c @@ -23,7 +23,7 @@ int apk_extract_file(int atfd, const struct apk_file_info *ae, const char *fn = extract_name ?: ae->name; int fd, r = -1, atflags = 0, ret = 0; - if (!(extract_flags & APK_EXTRACTF_NO_OVERWRITE)) { + if (!S_ISDIR(ae->mode) && !(extract_flags & APK_EXTRACTF_NO_OVERWRITE)) { if (unlinkat(atfd, fn, 0) != 0 && errno != ENOENT) return -errno; }