Skip to content
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

Merged
merged 4 commits into from
Oct 5, 2023

Conversation

tendstofortytwo
Copy link
Contributor

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 as SymbolicLink | File or SymbolicLink | Directory rather than just SymbolicLink.

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).

Signed-off-by: Naman Sood <mail@nsood.in>
src/node-explorer-provider.ts Outdated Show resolved Hide resolved
src/sftp.ts Outdated
Comment on lines 21 to 24
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('/');
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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/node-explorer-provider.ts Show resolved Hide resolved
src/sftp.ts Outdated
@@ -13,13 +13,30 @@ export class Sftp {
return this.sftpPromise;
}

async readSymbolicLink(path: string): Promise<string> {
Copy link
Contributor

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>
@tendstofortytwo tendstofortytwo merged commit a07d618 into main Oct 5, 2023
2 checks passed
@tendstofortytwo tendstofortytwo deleted the naman/follow-symbolic-links branch October 5, 2023 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File Explorer: Symbolic Links
2 participants