1

Closed

"File already exists" error when adding new file to a zip file

description

from discussion http://dotnetzip.codeplex.com/Thread/View.aspx?ThreadId=200380
 
Hi. Sorry it took so long to get the information about this problem. From the following job log, it looks like the file that's getting the "already exists" error is the DotNetZip temporary file, not the actual file name. Is this possible?

 

 
03:16:36 I The workflow has started
 
Start OK File processing.
 
03:16:36 I Activity 'ForEachFileOK' started
 
OK File: account_2010-03-06.ok
 
03:16:37 I Activity 'Archive' started
 
03:16:37 I Activity 'Archive' failed
 
03:16:37 E IOException in step 'Archive': The file '\tnt-chi-fs002\IRPT\Prod\SYS\DotNetZip-aovzxmue.tmp' already exists.
 
03:16:37 I Activity 'ForEachFileOK' failed
 
03:16:37 E IOException in step 'ForEachFileOK': The file '\tnt-chi-fs002\IRPT\Prod\SYS\DotNetZip-aovzxmue.tmp' already exists.
 
03:16:37 E The workflow has faulted
Closed Aug 2, 2011 at 7:07 PM by Cheeso
fixed in changeset 81459. First binary with this fix: v1.9.1.6

comments

ASCIJA wrote Mar 17, 2010 at 3:10 PM

Some additional information: this problem occurs when two workflows are running concurrently, both zipping different files from the same directory.

ASCIJA wrote Mar 25, 2010 at 2:32 PM

Hi,
Were you able to find anything about this?

Thanks

EmreAydinceren wrote Feb 16, 2011 at 12:07 AM

I could recreate the same problem with this sample code, I have a SSD, at about 110 I get the exception

var zipName = @"C:\files\test.zip";
        var zip = new Ionic.Zip.ZipFile(zipName);            

        var fileInfo = new FileInfo(@"C:\files\1k.txt");

        for(int i=0;i<1000;i++)
        {
            var fs = fileInfo.OpenRead();              

                zip.AddEntry(i + ".sql", fs);
                zip.Save();

            fs.Close();
            Console.WriteLine(i);

        }

Cheeso wrote Aug 1, 2011 at 10:20 PM

I can recreate this problem with no DotNetZip code at all - just calls to System.IO.File.Delete() and System.IO.File.Move(), done in a loop.

The call to File.Delete() appears to return before the file is actually, completely, really deleted.
I may need to insert a backoff-and-retry to handle this race condition. Need more research.

lcreagh wrote Feb 21, 2013 at 9:27 PM

Pursuant to the comment above about two workflows running concurrently and causing a temp file collision, I had a user get the following error when trying to add files to a zip. Below is the entire stack trace. Two things I don't understand:
  1. I haven't specified a separate path for zip temp files to go to, and I can't see them being created in the final zip directory, even though I am showing hidden files.
  2. Because of #1, I can't see why DotNetZip would be trying to create temp files in an E: path, since my app has no hardcoded paths, just relative ones, and the app is running on the C: drive.
Any ideas why DotNetZip might be trying to write temp files to E:(the rest of the path in the stack trace is my relative app path) and why I'm not seeing the temp files being created? How are folks working around this?

Thanks.

Laura

ERROR: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'E:\GIS_Sites\tcds\reports\output\68\scottk\zip\DotNetZip-ftnr3n4u.tmp'.
at Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at tcds_bulk_reports.btnBulkRpt_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)