4

Closed

CloseDelegate can be called twice

description

I'm trying to port Fiddler to DotNetZip from the Xceed library. However, I'm having a problem with the AddEntry(string, OpenDelegate, CloseDelegate) method. Specifically, sometimes my close delegate is getting called twice (but Open is called only once), and that leads to an exception. Any idea why this might happen?
 
thanks for any tips!
 
Exception:
Cannot access a closed Stream.;
at System.IO.MemoryStream.set_Position(Int64 value)
at Ionic.Zip.ZipEntry.PrepSourceStream()
at Ionic.Zip.ZipEntry.SetInputAndFigureFileLength(Stream& input)
at Ionic.Zip.ZipEntry._WriteEntryData(Stream s)
at Ionic.Zip.ZipEntry._EmitOne(Stream outstream)
at Ionic.Zip.ZipEntry.Write(Stream s)...

file attachments

Closed Jun 22, 2011 at 1:37 AM by Cheeso
This is fixed in a changeset prior to 79578. The fix will be in v1.9.1.6

comments

Cheeso wrote Mar 23, 2010 at 6:51 PM

Eric, pls try this version of the DLL. SHA1: FE6F317A6CB59C2E81A5AF78C97963140FEE7FC8

jpoehls wrote May 27, 2010 at 2:25 PM

I'm also having this same problem using the Ionic.Zip.Reduced.dll (version 1.9.5.2).

I tried using the Ionic.Zip.dll you attached and it fixed the problem. Is this fix part of a new official release yet?

Cheeso wrote Jun 2, 2010 at 10:30 PM

No - this fix is not yet part of any official release.
I never received confirmation on this.

rini wrote Nov 10, 2010 at 11:17 AM

I have the same problem using the AddEntry(string, OpenDelegate, CloseDelegate) method.
when the zipFile.CompressionLevel is left to Default value the close delegate is getting called twice leading to exception but when I set the zipFile.CompressionLevel to None the method runs with no exceptions.(actually all levels from level1 and up throw the same exception (Cannot access a closed file).
Any Ideas?
thanks!

nicolasmasse wrote Oct 18, 2011 at 10:43 AM

Same problem here with version 1.9.1.8. It seems that it happen when the readAgain variable in the ZipEntry.Write method is set to true after the first pass.
I fix this locally by adding this on line 1418 in ZipEntry.Write.cs :
  if (this._CloseDelegate != null)
  • {
      this._CloseDelegate(this.FileName, input);
  • this._sourceStream = null;
  • }
This makes the stream being reopened, avoiding crash

mika91 wrote Dec 12, 2011 at 4:26 PM

Hi,

same problem on 1.9.1.8 with very small files.

MarcosMeli wrote Jan 17, 2012 at 8:09 PM

@mika91

Confirmed in 1.9.1.8 Reduced

It throws: (Cannot access a closed file)

@Cheeso can you reopen it ?