weichsel / ZIPFoundation

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

Error while creating ZIP stream: The operation couldn’t be completed. (ZIPFoundation.Archive.ArchiveError error 0.) #247

Closed Strife91 closed 2 years ago

Strife91 commented 2 years ago

This happens when calling DFUFirmware(urlToZipFile: url) when using the iOSDFULibrary.

Firmware url: file:///var/mobile/Containers/Data/Application/6CF4B455-9787-4EFE-BEDC-D6A15DAA8524/Documents/firmwares/1-2.0.7.zip

Anyone know how to solve this problem?

weichsel commented 2 years ago

Maybe the zip archive at that path isn't a valid archive?

Not sure in what context you are experiencing this error. Are you using https://github.com/NordicSemiconductor/IOS-DFU-Library? Maybe you can look there if this is a known issue?

I am closing this for now. Feel free to re-open if the issue is related to unzipping.

Strife91 commented 2 years ago

Maybe the zip archive at that path isn't a valid archive?

Not sure in what context you are experiencing this error. Are you using https://github.com/NordicSemiconductor/IOS-DFU-Library? Maybe you can look there if this is a known issue?

I am closing this for now. Feel free to re-open if the issue is related to unzipping.

Yes. I'm using the IOS-DFU-Library. The error doesn't always occur. It seems to work when I launch the app for the first time.

I went to nordics issue page, but they recommended I come here. lol

weichsel commented 2 years ago

Can you verify that /var/mobile/Containers/Data/Application/6CF4B455-9787-4EFE-BEDC-D6A15DAA8524/Documents/firmwares/1-2.0.7.zip is a valid ZIP archive?

Strife91 commented 2 years ago

Can you verify that /var/mobile/Containers/Data/Application/6CF4B455-9787-4EFE-BEDC-D6A15DAA8524/Documents/firmwares/1-2.0.7.zip is a valid ZIP archive?

It seems the archive was corrupted. Probably because the app was interrupted during a write. To avoid this remember to add atomic to your write operation like below.

try data.write(to: folderPath.appendingPathComponent("\(fileName)"), options: [.atomic])

weichsel commented 2 years ago

Thanks for the update, great that you found the issue. Since this is unrelated to framework code, I'll leave the issue closed.