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

Directory mistaken for file #12

Open
kenlyon opened this issue Apr 26, 2017 · 2 comments
Open

Directory mistaken for file #12

kenlyon opened this issue Apr 26, 2017 · 2 comments
Labels

Comments

@kenlyon
Copy link

kenlyon commented Apr 26, 2017

I've encountered an error unzipping an archive that appears to be a special case. I'm actually using gulp-decompress but the cause appears to be in this module.

Symptoms:

  1. One of the directories within the zip file is incorrectly identified as a file instead of a directory.
  2. An empty file is created instead of a directory.
  3. The unzip operation fails when it then attempts to unzip the files within that directory as the OS attempts to create a directory of the same name as the file.

Possible cause:

  1. The entry in question has a externalFileAttributes value of 0x00110000. This fails the equality comparison with16 because 0x00100000 is set.

I don't know enough about what the 0x00100000 bit is for to know if getType(entry, mode) should really be just checking for 0x00010000 being set, rather than an exact equality.

I tested using new zip archives that I created with 7zip and Windows right-click > Send to > Compressed (zipped) folder. Both of them worked correctly.

I am unable to share the zip file here as it's an installer for licensed software. I also have no idea how it was produced. However, I am happy to answer any questions or run additional tests as needed.

@kenlyon
Copy link
Author

kenlyon commented May 10, 2017

Any update on this? It took a bit of effort to provide this level of detail. It'd be nice to get some feedback.

@hubgit
Copy link

hubgit commented Oct 27, 2020

This might help in some situations (as long as you're sure there aren't any real filenames ending with /):

  decompress(buffer, dir, {
    map: (file) => {
      if (file.type === 'file' && file.path.endsWith('/')) {
        file.type = 'directory'
      }
      return file
    },
  })

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

3 participants