weichsel / ZIPFoundation

Effortless ZIP Handling in Swift
MIT License
2.31k stars 255 forks source link

Error Unzip a file zipped with "shouldKeeyParent = false" #280

Closed Fahrenberg closed 8 months ago

Fahrenberg commented 1 year ago

Summary

I'm zipping with shouldKeepParent: false into a existing folder Unzipping this file results in a error and aborts unzipping.

zipping without shouldKeepParent works obviously as the directory is newly created by ZIPFoundation.

Steps to Reproduce

Zip with

try fm.zipItem(at: iCloudFilesURL, to: iCloudZipFile, shouldKeepParent: false)

unzip with

do {
    try fm.unzipItem(at: iCloudZipFile, to: iCloudExtractURL)
} catch {
    print(error)
}

Expected Results

adding all files in zip

Actual Results

aborts after trying add .DS_Store

Error Domain=NSCocoaErrorDomain Code=516 "The file “.DS_Store” couldn’t be saved in the folder “Extract” because a file with the same name already exists." UserInfo={NSFilePath=/Users/JeanNicolas/Library/Mobile Documents/com~apple~CloudDocs/Programmierung/Swift/Test/Zipping/Extract/.DS_Store}

Regression & Version

Related Link

Fahrenberg commented 1 year ago

Work around:


do {
    if let entry = archive[".DS_Store"] {
        try archive.remove(entry)
    }
    try fm.unzipItem(at: iCloudZipFile, to: iCloudExtractURL)
    listFiles(url: iCloudExtractURL)
} catch {
    print(error)
}
weichsel commented 8 months ago

Duplicate of https://github.com/weichsel/ZIPFoundation/issues/54