-
Notifications
You must be signed in to change notification settings - Fork 3
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
Node Explorer: follow symbolic links to directories #249
Conversation
Signed-off-by: Naman Sood <mail@nsood.in>
src/sftp.ts
Outdated
if (!result.startsWith('/')) { | ||
// split path by separator, slice away the last bit to get the parent directory, | ||
// append the relative path, and join it back together | ||
result = [...path.split('/').slice(0, -1), result].join('/'); |
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.
Given the /
, does this work for "shortucts" on windows? Why not use path.dirname
?
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 did not know path.dirname
existed. 😅 I can switch to using that now.
I'm going to guess that this doesn't work with shortcuts on Windows, since those are a completely different mechanism from symbolic links. Windows also has symbolic links and I would guess that this would work with those (but I have no way of checking, since I don't own a Windows PC).
The path here is a URI, so it should use /
regardless of platform.
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.
Update: this doesn't work for anything on a Windows remote, because Tailscale SSH does not support Windows at the moment. 😅
src/sftp.ts
Outdated
@@ -13,13 +13,30 @@ export class Sftp { | |||
return this.sftpPromise; | |||
} | |||
|
|||
async readSymbolicLink(path: string): Promise<string> { |
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.
Can we also add some unit tests for this function?
Signed-off-by: Naman Sood <mail@nsood.in>
Signed-off-by: Naman Sood <mail@nsood.in>
Signed-off-by: Naman Sood <mail@nsood.in>
Fixes #209.
The biggest change in this PR is that we'll be treating
vscode.FileType
as a bitfield now, rather than just checking for equality, since the SFTP file provider is modified to return symlinks asSymbolicLink | File
orSymbolicLink | Directory
rather than justSymbolicLink
.Also, should wait for @shayne (or someone else) to confirm that SFTP to a Windows host still uses
/
as the path separator before merging (unfortunately I don't have a Windows machine to test).