-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unzip aborts when a file being unzipped already exists #54
Comments
The In the meantime, you can manually instantiate an Archive and iterate over all entries: guard let archive = Archive(url: archiveURL, accessMode: .read) else {
return
}
for entry in archive {
// Perform extraction here and skip for already existing entries
try? archive.extract(entry, to: destinationURL)
} |
thanks,
…On Mon, Mar 19, 2018 at 4:40 AM, Thomas Zoechling ***@***.***> wrote:
The unzipItem method in the FileManager extension currently only supports
simple extraction of an archive to an empty destination. I plan to add a
delegate protocol (similar to the FileManagerDelegate
<https://developer.apple.com/documentation/foundation/filemanagerdelegate>
of Foundation) in the future. This will allow custom actions before- or
after individual entry extraction.
In the meantime, you can manually instantiate an Archive and iterate over
all entries:
guard let archive = Archive(url: archiveURL, accessMode: .read) else {
return
}for entry in archive {
// Perform extraction here and skip for already existing entries try? archive.extract(entry, to: destinationURL)
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#54 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/Aeu_-d0jt47Xscc3NM5TaL4cg0ZDEEAiks5tf30WgaJpZM4Su3pd>
.
|
Hi @weichsel I want to extract each files in .zip into a folder. And this folder has other files which can not be removed. So I need to extract my default data from .zip into that folder which default data sometimes modified. How could I replace the existing file? I do the solution like above which you provide. But still face the same error. Error Domain=NSCocoaErrorDomain Code=516 "The file “acc_head077_ch011.png” couldn’t be saved in the folder “DefaultData” because a file with the same name already exists." " UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/71AD1914-4645-43D8-ACB2-14199BF24A65/Documents/AvatarDefaultData/acc_head077_ch011.png} Here is my code guard let archive = Archive(url: sourceURL, accessMode: .read) else {
return
}
for entry in archive {
let destinationEntryURL = destinationURL.appendingPathComponent(entry.path)
_ = try archive.extract(entry, to: destinationEntryURL)
} What do I miss? Thanks for the reply |
You have to manually check for the items existence and then remove it via |
Got it! |
I've trying to do this but the performance is so terrible. Has any way to make it faster |
Are you running a debug build? There is a huge difference between debug and release builds. |
Any news? |
Summary
Unzip aborts when a file being unzipped already exists
not unzipped Error Domain=NSCocoaErrorDomain Code=516 "The file “Painted_Bunting_184832.jpg” couldn’t be saved in the folder “Documents” because a file with the same name already exists." UserInfo={NSFilePath=/var/mobile/Containers/Data/Application/9C36C53F-A273-4C59-BCFB-241CA89ED18F/Documents/Painted_Bunting_184832.jpg}
I think there should be a way to configure abort/overwrite/skip for this situation. I need anything but abort. How can I change that? Thanks!
Steps to Reproduce
Expected Results
Actual Results
Regression & Version
Related Link
The text was updated successfully, but these errors were encountered: