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.
cute-signatures
Timo Teräs 2021-08-03 21:47:19 +03:00
parent b30e94c0ac
commit f446f2253d
1 changed files with 1 additions and 1 deletions

View File

@ -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;
}