Cannot unpack read-only dirs
lheckemann opened this issue · 4 comments
lheckemann commented
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.
TheFeelTrain commented
I am having the same issue.
TheFeelTrain commented
Nevermind, this worked for me @lheckemann
var extract = tar.extract('./my-directory', {
readable: true,
writable: true
})
lheckemann commented
Sure, but that's only helpful if you actually want to override the permissions from the tarball.
mafintosh commented
PR welcome! We probably have to chmod the file after writing it.