1

Closed

File handles persist after calling Dispose() when extracting spanned ZIP

description

an issue when extracting spanned archives created with DotNetZip. My code is written in PowerShell.
 
Code to create the spanned archive:
 
$zipfile = new-object Ionic.Zip.ZipFile
$zipfile.UseZip64WhenSaving = [Ionic.Zip.Zip64Option]::AsNecessary
$zipfile.AddDirectory($inputDir.fullname)
$zipfile.MaxOutputSegmentSize = $archiveSegmentSize # 40MB
$zipfile.Save($archiveFile.Fullname)
 

 
Code to extract the spanned archive:
 
 
$zip = [Ionic.Zip.ZipFile]::Read($Zipfile.Fullname)
$zip.ExtractExistingFile = [Ionic.Zip.ExtractExistingFileAction]::OverwriteSilently
$zip.ExtractAll($OutputDirectory.FullName)
$zip.Dispose()
 
 
This will create and then extract a spanned archive with say about 5 segments. What I've noticed is that after the spanned archive is extracted, file handles to the archive segments are not closed for most of the segments after calling the Dispose() method. This means the
segment files cannot be deleted because they are still in use.
 
This also seems to be the case when extracting a spanned archive with the DotNetZip-WinFormsTool program.
 
When I tried the same code to extract a non-spanned ZIP created with DotNetZip, the file handle was closed and I could delete the ZIP file after.
Closed Jun 15, 2011 at 7:04 PM by Cheeso
this is fixed in changeset 79174. The first binary to get this fix is v1.9.1.6.

comments

antize wrote Dec 21, 2010 at 8:47 PM

Just would like to add the comment that posted in the discussion section:

It looks like the file handles get cleaned up after a bit of time which suggests the garbage collector is doing it. So I've added this to my PowerShell code and it seems to resolve the issue for now: