Using DotNetZip 22.214.171.124.
While adding an entry to an existing zip file containing approx. 9000 entries, my server shutdown unexpectedly.
On reboot, I found out that the original file was corrupt:
Ionic.Zip.BadReadException: ZipEntry::ReadHeader(): Bad signature (0x00000000) at position 0x00000000
at Ionic.Zip.ZipEntry.ReadHeader(ZipEntry ze, Encoding defaultEncoding)
at Ionic.Zip.ZipEntry.ReadEntry(ZipContainer zc, Boolean first)
at Ionic.Zip.ZipFile.ReadIntoInstance_Orig(ZipFile zf)
at Ionic.Zip.ZipFile.ReadIntoInstance(ZipFile zf)
at Ionic.Zip.ZipFile.Read(String fileName, TextWriter statusMessageWriter, Encoding encoding, EventHandler`1 readProgress)
at Ionic.Zip.ZipFile.Read(String fileName)
In the same directory, I found the temporary file (DotNetZip-XXXXXX). After changing the extension to .zip, I can't seem to open it either. This is unexpected for me. I thought the temporary file was a copy of the zip file, with the new entry. Here is my
expected behavior if the system shutdown during Save():
- The original zip file is left untouched, and the DotNetZip-XXXXXX file is corrupt. (stopped while building the new file)
- The original zip file is corrupt, and the DotNetZip-XXXXXX file is okay. (stopped while overwriting the original file)
Here is the calling code:
SaveZipHandler opens a Stream to the file before saving each entry.
using (ZipFile zip = ZipFile.Read(this.OutputFile))
zip.ParallelDeflateThreshold = -1; //Do not multi-thread inner operations.
zip.BufferSize = 20480;
zip.CompressionLevel = CompressionLevel.BestCompression;
zip.UseZip64WhenSaving = Zip64Option.AsNecessary;
zip.SaveProgress += this.SaveZipHandler;
foreach (var entry in entries)
//Simply queue the right amount of entries.
zip.SaveProgress -= this.SaveZipHandler;
Please tell be how DotNetZip is supposed to manage transactional zipping, and what is the behavior is the system shuts down during the save.