Skip to content

Commit 1a3205d

Browse files
authoredNov 19, 2022
Remove unneeded and buggy stats check (#976)
As per nodejs/node#39372 (comment) Resolves #918
1 parent b3146f0 commit 1a3205d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎lib/copy/copy-sync.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ function onLink (destStat, src, dest, opts) {
146146
// prevent copy if src is a subdir of dest since unlinking
147147
// dest in this case would result in removing src contents
148148
// and therefore a broken symlink would be created.
149-
if (fs.statSync(dest).isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
149+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
150150
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
151151
}
152152
return copyLink(resolvedSrc, dest)

‎lib/copy/copy.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function onLink (destStat, src, dest, opts, cb) {
219219
// do not copy if src is a subdir of dest since unlinking
220220
// dest in this case would result in removing src contents
221221
// and therefore a broken symlink would be created.
222-
if (destStat.isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
222+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
223223
return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`))
224224
}
225225
return copyLink(resolvedSrc, dest, cb)

0 commit comments

Comments
 (0)
Please sign in to comment.