Bug when compressing .rar or .zip file

Aug 24, 2010 at 10:02 AM

Hi,

I found a bug, when compressing(actually archiving) a .rar or .zip file into segments, particularly if the file is large enough to generate more than one segment, DotNetZip will throw a "FileNotFoundException", saying that the XXX.z01 doesn't exists.  From the code, it seems the method WantReadAgain(file: ZipEntry.Writer.cs) returns true if compressed size is larger than original size, and that will direct to method "TruncateBackward" (file: ZipSegmentedStream.cs) which generates the exception.

the exception is thrown from the following code:

// get a new temp file, try 3 times:
            for (int i = 0; i < 3; i++)
            {
                try
                {
                    _currentTempName = SharedUtilities.InternalGetTempFileName();
                    File.Move(CurrentName, _currentTempName);  // move the .z0x file back to a temp name
                }
                catch(IOException)
                {
                    if (i == 2) throw;
                }
            }

 

Coordinator
Aug 25, 2010 at 11:40 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.