haf / DotNetZip.Semverd

Please use System.IO.Compression! A fork of the DotNetZip project without signing with a solution that compiles cleanly. This project aims to follow semver to avoid versioning conflicts. DotNetZip is a FAST, FREE class library and toolset for manipulating zip files. Use VB, C# or any .NET language to easily create, extract, or update zip files.
Other
545 stars 218 forks source link

zip.ExtractAll() System.IO.IOException: 'Cannot create a file when that file already exists. #293

Open Mehuge opened 4 months ago

Mehuge commented 4 months ago

Trying to extract a node_modules zip, and hitting this exception early on. The extract is left with a .tmp file on one of the nested folders.

I cut down the node_modules.zip and copied one problem folder around and it seems the be the level of nesting of the folder that is causing the problem.

private void button1_Click(object sender, EventArgs e)
{
  using (ZipFile zip = new ZipFile("C:\\DEV\\WindowsFormsApp1\\node_modules.zip"))
  {
    zip.ExtractAll("C:\\DEV\\WindowsFormsApp1\\");
  }
}

Folder structure in the ZIP

dist
  esm
    estree-walker.js
node_modules
  dist
    esm
      estree-walker.js
  estree-walker
    dist
      esm
        estree-walker.js

(the dist folder was replicated at different levels in the zip for testing, originally just under estree-walker folder)

The resuting output is

dist
   esm
      estree-walker.js
node_modules
  dist
    esm
      estree-walker.js
  estree-walker
    dist
      DotNetZip-ulvesib3.tmp

and the above exception.

node_modules.zip