Repository navigation
[meta] Use the vscode filesystem API for *all* filesystem operations. #8533
Copy link
Copy link
Closed
Labels
area-internalLabel for non-user facing issuesLabel for non-user facing issuesdebtCode quality issuesCode quality issuesmetaIssue that is tracking an overall projectIssue that is tracking an overall project
Description
With version , VS Code added a new filesystem API, to provide a consistent and reliable experience on different platforms and execution environments (including remote). The extension should use it as much as possible.
The API
vscode.workspace.fs.*
copy(source: Uri, target: Uri, options?: {overwrite: boolean}): Thenable<void>
createDirectory(uri: Uri): Thenable<void>
delete(uri: Uri, options?: {recursive: boolean, useTrash: boolean}): Thenable<void>
readDirectory(uri: Uri): Thenable<[string, FileType][]>
readFile(uri: Uri): Thenable<Uint8Array>
rename(source: Uri, target: Uri, options?: {overwrite: boolean}): Thenable<void>
stat(uri: Uri): Thenable<FileStat>
writeFile(uri: Uri, content: Uint8Array): Thenable<void>
vscode.FileStat
vscode.FileType
For reference:
How to Switch?
PRs:
- Update the code base to use IFileSystem instead of fs and fs-extra. #7915 (for Use VS Code FS API #6911)
- Use new VS Code filesystem API. #8307 (for Use VS Code FS API #6911)
Tasks:
- identify all current filesystem usage (see [meta] Code health for filesystem interaction. #8801)
- consolidate all filesystem usage into
IFileSystem(see [meta] Code health for filesystem interaction. #8801) - ensure we keep using only our wrapper in the future (see [meta] Code health for filesystem interaction. #8801)
- improve testability (see [meta] Code health for filesystem interaction. #8801)
- use the
vscode.workspace.fsAPI as a replacement:- node's "fs" module is completely subsumed by "fs-extra"
- "fs-extra" module
- (missing)
chmod()-> ??? - (Use VS Code FS API #6911)
readFile()->readFile() - (Use VS Code FS API #6911)
writeFile()->writeFile() - (Use VS Code FS API #6911)
unlink()->delete() - (Use VS Code FS API #6911)
stat()->stat() - (missing)
lstat()-> ???- covered by File Provider: support symbolic link operations vscode#71204
- maybe use
stat()instead?
- (Use VS Code FS API #6911)
mkdirp()->createDirectory() - (Use VS Code FS API #6911)
rmdir()->delete() - (Use VS Code FS API #6911)
readdir()-> `readDirectory() - (Use VS Code FS API #6911)
remove()->delete()- this is a recursive delete (i.e.
rmtree())
- this is a recursive delete (i.e.
- (TODO)
statSync()-> ???- per Support for sync functions in the vscode.workspace.fs API. vscode#84518, not going to happen
- switch from sync to async?
- (TODO)
readFileSync()-> ???- per Support for sync functions in the vscode.workspace.fs API. vscode#84518, not going to happen
- switch from sync to async?
- (Use VS Code FS API #6911)
createReadStream()- goes away once we usecopy() - (Use VS Code FS API #6911) stop using
createWriteStream()forcopy() - (missing)
createWriteStream()-> ???
- (missing)
- "tmp" module
- (missing)
file()-> ???
- (missing)
- "glob" module
- (TODO)
glob()->vscode.workspace.findFiles()
- (TODO)
- ...
- drop workarounds
- (TODO) drop tree traversal code (per Add vscode.workspace.fs.mkdirp(). vscode#84516)
- (blocked)
FileStat.ctime==0- reported:
vscode.workspace.fs.stat(): wrong creation time. vscode#84525 - drop: ...
- reported:
- (blocked) unexpected successes
- reported: vscode.workspace.fs.remove() (and copy()) succeed unexpectedly. vscode#84177
- drop: ...
- (blocked) sockets as
FileType.File- reported:
vscode.workspace.fs.stat(): sockets identified as "regular" files. vscode#84524 - drop: ...
- reported:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-internalLabel for non-user facing issuesLabel for non-user facing issuesdebtCode quality issuesCode quality issuesmetaIssue that is tracking an overall projectIssue that is tracking an overall project
Activity
Use new VS Code filesystem API. (#8307)
ericsnowcurrently commentedon May 14, 2020
FWIW, I'm not sure this is totally done (would have to check), but it's probably better closed for now. We can revive it or dupe it later if that turns out to matter.