Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows does not identify folders correctly in zip #46

Open
binary-koan opened this issue Dec 9, 2016 · 7 comments
Open

Windows does not identify folders correctly in zip #46

binary-koan opened this issue Dec 9, 2016 · 7 comments
Labels

Comments

@binary-koan
Copy link

binary-koan commented Dec 9, 2016

I'm trying to extract https://github.com/HaxeFoundation/haxe/releases/download/3.2.1/haxe-3.2.1-win.zip using decompress 4.0.0, but get a whole bunch of errors like

Error: EISDIR: illegal operation on a directory, open '...\haxe-3.2.1\std\flash\geom'
    at Error (native)
  errno: -4068,
  code: 'EISDIR',
  syscall: 'open',
  path: '...\haxe-3.2.1\std\flash\geom'

from file entries like

{ mode: 420,
  mtime: 2015-10-11T11:00:44.000Z,
  path: 'haxe-3.2.1/std/flash/geom/',
  type: 'file',
  data: <Buffer > }

It looks like the directories in that archive are marked as type: file (instead of directory), but oddly enough it only happens for that particular archive.

A quick fix I found was to treat files as directories if their path ends with a '/' (i.e. if (x.type === 'directory' || x.path.endsWith('/')) { /* mkdir -p */ }), but I don't know if that's a good idea or not.

@kevva kevva added the bug label May 25, 2017
@vislamov
Copy link

vislamov commented Nov 7, 2017

Same here, switching to another lib...

@hzqst
Copy link

hzqst commented Jan 18, 2018

Same issue, switching to another lib tooooo...

@jeffmcaffer
Copy link

jeffmcaffer commented Feb 11, 2018

Same here. This is preventing temporarily unzip'd folders from being deleted (they are not empty) because the files in them are left open. fs.unlink marks them for deletion but does not empty the folder entry.

Moved to https://www.npmjs.com/package/extract-zip and that seems to work.

@dabutvin
Copy link

dabutvin commented Oct 9, 2018

FWIW I had success working around this using a filter

decompress(source, destination, {
  filter: file => !file.path.endsWith('/')
})

dabutvin pushed a commit to dabutvin/crawler that referenced this issue Oct 9, 2018
 - getting EISDIR errors during tmp cleanup
 - the file was getting wrongly unzipped as a file instead of a folder
 - this updates to just skip the folders
 - see kevva/decompress#46
@ahkohd
Copy link

ahkohd commented Aug 26, 2019

FWIW I had success working around this using a filter

decompress(source, destination, {
  filter: file => !file.path.endsWith('/')
})

Worked like a charm, thanks!

@stheine
Copy link

stheine commented Apr 19, 2023

The error is described in the module that's used for unzip: kevva/decompress-unzip#12

@LichKing-2234
Copy link

LichKing-2234 commented May 6, 2023

In my case, the file path does not end with '/'. But the data is empty. So the filter can be optimized:

const path = require('path');
...
filter: (file) => {
      return (
        file.type !== 'directory' &&
        !file.path.endsWith(path.sep) &&
        file.data.length !== 0
      );
    },

qtomlinson pushed a commit to qtomlinson/crawler that referenced this issue Feb 6, 2024
 - getting EISDIR errors during tmp cleanup
 - the file was getting wrongly unzipped as a file instead of a folder
 - this updates to just skip the folders
 - see kevva/decompress#46
vikivakarvc added a commit to vikivakarvc/clearlydefined-crawler that referenced this issue Aug 6, 2024
 - getting EISDIR errors during tmp cleanup
 - the file was getting wrongly unzipped as a file instead of a folder
 - this updates to just skip the folders
 - see kevva/decompress#46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants