windows: Fix extension uninstall (#18467)
Closes #18153 When calling `uninstall_extension`, the `work_dir` associated with this `extension` doesn't have its corresponding `FileHandle` properly closed, preventing the deletion of the `work_dir`. As seen in the image below, after installing the `toml` extension, `zed.exe` holds two `Handle`s for the folder `C:\Users\36477\AppData\Local\Zed\extensions\work\toml`.  Therefore, after deleting `extension_dir` and then calling `this.update(...)`, `zed.exe` releases these two `Handles`, and only then can the folder `C:\Users\36477\AppData\Local\Zed\extensions\work\toml` be deleted. See the corresponding file handles are closed after calling `this.update(...)`:  However, if there is a running server of the extension, the error will persist. At this point, I haven’t found a direct way to terminate all running servers of the extension. Since this feature might affect the `LspStore` structure, I paused my work here. See when `toml` extension is running, we can not delete `C:\Users\36477\AppData\Local\Zed\extensions\work\toml` since `C:\Users\36477\AppData\Local\Zed\extensions\work\toml\taplo.exe` is still running:  cc @ConradIrwin You're the expert in this area—what are your thoughts? Release Notes: - N/A
This commit is contained in:
parent
bb15f4c493
commit
9f72e05c40
1 changed files with 12 additions and 9 deletions
|
@ -837,15 +837,6 @@ impl ExtensionStore {
|
|||
}
|
||||
});
|
||||
|
||||
fs.remove_dir(
|
||||
&work_dir,
|
||||
RemoveOptions {
|
||||
recursive: true,
|
||||
ignore_if_not_exists: true,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
fs.remove_dir(
|
||||
&extension_dir,
|
||||
RemoveOptions {
|
||||
|
@ -855,7 +846,19 @@ impl ExtensionStore {
|
|||
)
|
||||
.await?;
|
||||
|
||||
// todo(windows)
|
||||
// Stop the server here.
|
||||
this.update(cx, |this, cx| this.reload(None, cx))?.await;
|
||||
|
||||
fs.remove_dir(
|
||||
&work_dir,
|
||||
RemoveOptions {
|
||||
recursive: true,
|
||||
ignore_if_not_exists: true,
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.detach_and_log_err(cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue