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

Multi root: files are allowed as folder? #93366

Closed
bpasero opened this issue Mar 25, 2020 · 10 comments
Closed

Multi root: files are allowed as folder? #93366

bpasero opened this issue Mar 25, 2020 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded workbench-multiroot Multi-root (multiple folders) issues
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Mar 25, 2020

I am surprised to see that I can add a literal file path into my workspace config and have it appear as a node in the explorer:

image

This is only asking for trouble I would say, e.g we try to install a file watcher on the file assuming it is a folder.

I think we should ignore such an entry from the workspace if we detect it is a file and not a folder.

//cc @isidorn

@bpasero bpasero added bug Issue identified by VS Code Team member as probable bug workbench-multiroot Multi-root (multiple folders) issues labels Mar 25, 2020
@sandy081
Copy link
Member

I never validate the added path/uri in the workspace - neither for existence nor file type.
@isidorn May be this validation shall also go to explorer?

@bpasero
Copy link
Member Author

bpasero commented Mar 25, 2020

While I think the explorer should not show the file as folder as it happens today, I think some kind of validation needs to happen on the level of the workspace service. Otherwise e.g. extensions are seeing the file as workspace folder even though it is a file.

Not sure how to best fix this to be honest. I would not want to block the startup to verify the file type because it could be a remote URI that takes long to resolve...

@isidorn
Copy link
Contributor

isidorn commented Mar 25, 2020

@sandy081 yes I can do the validation in the Explorer. But yeah idealy the validation would happen before on the worskapce service level. If that is not possible, let me know and I will add validation on the explorer level as a workaround.

@sandy081
Copy link
Member

I can do the validation after initialisation so that it does not block the start up. So validation removes the file from workspace folders. In case of non existing folders we validate while rendering. Does not this cause inconsistency? Is not it better for user to see it in the explorer and let the user to remove it instead of silently hiding?

@isidorn
Copy link
Contributor

isidorn commented Mar 26, 2020

Having a non existing folder can be caused by not manually editiing the workspace json file. User nicely adds a folder, and after a couple of days deletes it and then reopen the workspace.
Having a file there can only be done by manualy editing the workspace setting file. Thus I think it will happen much more rarely. Thus I do not care that much if we guide the user to fix this.
So just filtering out on the first level is perfectly fine imho

@sandy081 sandy081 added this to the March 2020 milestone Mar 26, 2020
@sandy081
Copy link
Member

Makes sense. Added folder validation to workspace service.

@bpasero I still see following errors while resolving invalid paths

Error: Unable to read file '/Users/sandy081/work/vscode/package.json/.vscode/launch.json' (Unknown (FileSystemError): Error: ENOTDIR: not a directory, open '/Users/sandy081/work/vscode/package.json/.vscode/launch.json')

Currently file service is returning FILE_OTHER_ERROR . Is it possible to get a specific error?

sandy081 added a commit that referenced this issue Mar 26, 2020
@bpasero
Copy link
Member Author

bpasero commented Mar 26, 2020

@sandy081 I added FileOperationResult.FILE_NOT_DIRECTORY just now.

How would this work now, are you validating the folder being an actual folder async and then remove it from your list of workspaces but keep it in the workspace file?

@bpasero
Copy link
Member Author

bpasero commented Mar 26, 2020

@sandy081 looks like this error code does not work on Windows at least, Windows is throwing ENOTFOUND when trying to resolve a file that has a file as parent.

@sandy081
Copy link
Member

How would this work now, are you validating the folder being an actual folder async and then remove it from your list of workspaces but keep it in the workspace file?

Yes. I only remove it in memory and keep it in workspace file. And regarding validation, I am not blocking the initialisation.

// Not waiting on this validation to unblock start up
this.validateWorkspaceFoldersAndReload();

I will use both FileOperationResult.FILE_NOT_DIRECTORY and FileOperationResult.FILE_NOT_FOUND

sandy081 added a commit that referenced this issue Mar 26, 2020
@bpasero
Copy link
Member Author

bpasero commented Mar 26, 2020

Great, thanks for the fast turnaround.

@bpasero bpasero added the verified Verification succeeded label Apr 2, 2020
@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded workbench-multiroot Multi-root (multiple folders) issues
Projects
None yet
Development

No branches or pull requests

3 participants