-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(fs): fix copying of symlink directories on Windows #6278
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6278 +/- ##
=======================================
Coverage 96.34% 96.34%
=======================================
Files 543 543
Lines 41601 41601
Branches 6312 6310 -2
=======================================
+ Hits 40079 40081 +2
+ Misses 1478 1477 -1
+ Partials 44 43 -1 ☔ View full report in Codecov by Sentry. |
@kt3k The reason is that in the |
@@ -137,7 +137,7 @@ async function copySymLink( | |||
) { | |||
await ensureValidCopy(src, dest, options); | |||
const originSrcFilePath = await Deno.readLink(src); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Deno.realPath
should return the absolute path of the symlink target. Additional explanation for suggestion in PR #6236:
const originSrcFilePath = await Deno.readLink(src); | |
const originSrcFilePath = await Deno.realPath(src); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think changing this to realPath
causes another problem. I think we should keep this work for relative symlinks.
@@ -161,7 +161,7 @@ function copySymlinkSync( | |||
) { | |||
ensureValidCopySync(src, dest, options); | |||
const originSrcFilePath = Deno.readLinkSync(src); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Deno.realPathSync
should return the absolute path of the symlink target. Additional explanation for suggestion in PR #6236:
const originSrcFilePath = Deno.readLinkSync(src); | |
const originSrcFilePath = Deno.realPathSync(src); |
@@ -137,7 +137,7 @@ async function copySymLink( | |||
) { | |||
await ensureValidCopy(src, dest, options); | |||
const originSrcFilePath = await Deno.readLink(src); | |||
const type = getFileInfoType(await Deno.lstat(src)); | |||
const type = getFileInfoType(await Deno.lstat(originSrcFilePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this only works when originSrcFilePath
is an absolute path or relative path accidentally points to path accessible from cwd. originSrcFilePath
could be relative path from link path to target, which could be inaccessible from cwd
, and in that case this lstat
call would fail.
I think this should Deno.stat(src)
instead with fallback to 'file' type in case Deno.stat(src)
throws NotFound. What do you think?
This PR fixes the handling of symlink directories in the
copy
function on Windows. Previously, copying a directory that was a symlink resulted in creating a symlink of type"file"
instead of"dir"
.The test case for copying symlink directories passed because
Deno.lstat()
(which does not follow symlinks) was used. However, whenDeno.stat()
(which follows symlinks) was used on this type of symlink, the system would throw aPermissionDenied
error.