Skip to content

Commit fe73a03

Browse files
committed
Remove unneeded and buggy stats check
As per nodejs/node#39372 (comment) Resolves #918
1 parent 0220eac commit fe73a03

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

lib/copy/copy-sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function onLink (destStat, src, dest, opts) {
154154
// prevent copy if src is a subdir of dest since unlinking
155155
// dest in this case would result in removing src contents
156156
// and therefore a broken symlink would be created.
157-
if (fs.statSync(dest).isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
157+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
158158
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
159159
}
160160
return copyLink(resolvedSrc, dest)

lib/copy/copy.js

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

0 commit comments

Comments
 (0)