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

How to stat a directory using IFileService? #143394

Closed
alexdima opened this issue Feb 18, 2022 · 4 comments
Closed

How to stat a directory using IFileService? #143394

alexdima opened this issue Feb 18, 2022 · 4 comments
Assignees
Labels
file-io File I/O insiders-released Patch has been released in VS Code Insiders
Milestone

Comments

@alexdima
Copy link
Member

For #142078 , I am trying to replace pfs with IFileService.

Here I need to read the mtime of a directory. I could not find IFileService.stat so I am trying to use IFileService.resolve().

However, I have noticed that IFileService.resolve() returns all children for a directory, which in the case of the builtin extensions directory is about 100 children, and I am concerned that this might be costly. Is there a way to stat a directory without reading its children?

@bpasero bpasero added the file-io File I/O label Feb 19, 2022
@bpasero bpasero added this to the February 2022 milestone Feb 19, 2022
@bpasero
Copy link
Member

bpasero commented Feb 19, 2022

There is now IFileService.stat that will not resolve children.

@gjsjohnmurray
Copy link
Contributor

@bpasero is your change relevant / applicable to extensions, either ones that implement a FileSystemProvider or ones that use vscode.workspace.fs.stat() to learn about a folder?

@bpasero
Copy link
Member

bpasero commented Feb 19, 2022

@gjsjohnmurray extensions have a more primitive form of API and can use vscode.fs.stat which is pretty much the same as the internal API I now added.

In March debt week I might see to adopt this new IFileService.stat method over IFileService.resolve given it is probably faster in most cases where the children are not required.

@alexdima
Copy link
Member Author

Nice! Thank you @bpasero !

@github-actions github-actions bot locked and limited conversation to collaborators Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
file-io File I/O insiders-released Patch has been released in VS Code Insiders
Projects
None yet
Development

No branches or pull requests

4 participants
@bpasero @alexdima @gjsjohnmurray and others