Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

fstream.Reader({ path: ..., type: 'Directory' }) interacts badly with tar and non-writeable files #28

Open
estark37 opened this issue Oct 1, 2014 · 0 comments

Comments

@estark37
Copy link

estark37 commented Oct 1, 2014

If you use fstream.Reader({ path: <path>, type: 'Directory' }) and tar to tar up a directory whose first entry is a non-writeable file, you can't untar it with tar. It works fine if you use fstream.Reader(<path>) instead. Here's a reproduction:

https://github.com/estark37/fstream-eacces-bug

$ npm install
$ node index.js
... tars and untars example/ fine
$ node index.js bad
... EACCES on untar

The only difference when you add the bad argument is that it uses fstream.Reader({ path: <path>, type: 'Directory' }) instead of fstream.Reader(<path>).

I think there are two issues here:

  1. The "bad" argument to fstream.Reader causes the outputted tarball to not contain an entry for the top-level example/ directory. I didn't dig into this too much, but it sort of looked like the reader was immediately emitting an entry for the top-level directory, but without any permissions or other properties. This entry was getting emitted before the pipe to the writer was set up, so it was being lost. If I paused all the streams until all the pipes were set up, the tarball would come out with an entry for the top-level directory but with permissions 0000.
  2. When fstream.Writer (as part of untarring) makes the first entry in the tarball (example/f), it creates example/ with the same permissions as f. It seems to me that example/ should perhaps come out with default permissions if it doesn't have an entry for example/, not with the permissions of example/f.

When using fstream.Reader(<path>), the tarball comes out with an entry for the top-level directory with the correct permissions.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant