Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit a1a1fb8

Browse files
pirannamafintosh
authored andcommitted
Allow to create a file when filesystem don't support hard links (#44)
* Allow to create a file when filesystem don't support hard links * Changed option name from `allowCreateFilesForHardLinks` to `hardlinkAsFilesFallback`
1 parent ebc956e commit a1a1fb8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,16 @@ exports.extract = function (cwd, opts) {
247247
var onlink = function () {
248248
if (win32) return next() // skip links on win for now before it can be tested
249249
xfs.unlink(name, function () {
250-
xfs.link(path.resolve(cwd, header.linkname), name, stat)
250+
var srcpath = path.resolve(cwd, header.linkname)
251+
252+
xfs.link(srcpath, name, function (err) {
253+
if (err && err.code === 'EPERM' && opts.hardlinkAsFilesFallback) {
254+
stream = xfs.createReadStream(srcpath)
255+
return onfile()
256+
}
257+
258+
stat(err)
259+
})
251260
})
252261
}
253262

0 commit comments

Comments
 (0)