mafintosh/tar-fs

Cannot unpack read-only dirs

lheckemann opened this issue · 4 comments

tar-fs seems to set permissions on the directories too early, preventing itself from later writing their contents.

Minimal example:

const tar = require("tar-fs")
const fs = require("fs")

fs.createReadStream("ro.tar").pipe(tar.extract("ro-extracted"))

With https://sphalerite.org/dump/ro.tar in the CWD, this results in:

events.js:183
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open 'ro-extracted/ro/foo'

Since the directory ro is created read-only. GNU tar creates the ro directory read-write, and only sets it read-only after populating it, resulting in a successful extraction.

I am having the same issue.

Nevermind, this worked for me @lheckemann

var extract = tar.extract('./my-directory', {
  readable: true,
  writable: true
})

Sure, but that's only helpful if you actually want to override the permissions from the tarball.

PR welcome! We probably have to chmod the file after writing it.