Remove old extension dir when upgrading (#9800)
Fixes #9799 Release Notes: - Fixed a bug where upgrading an extension did not work correctly if the extension had switched from using an old extension schema with `extension.json` to the new schema with `extension.toml`.
This commit is contained in:
parent
5adc51f113
commit
5e7fcc02fa
1 changed files with 15 additions and 6 deletions
|
@ -437,8 +437,9 @@ impl ExtensionStore {
|
||||||
operation: ExtensionOperation,
|
operation: ExtensionOperation,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) {
|
) {
|
||||||
let extensions_dir = self.extensions_dir();
|
let extension_dir = self.installed_dir.join(extension_id.as_ref());
|
||||||
let http_client = self.http_client.clone();
|
let http_client = self.http_client.clone();
|
||||||
|
let fs = self.fs.clone();
|
||||||
|
|
||||||
match self.outstanding_operations.entry(extension_id.clone()) {
|
match self.outstanding_operations.entry(extension_id.clone()) {
|
||||||
hash_map::Entry::Occupied(_) => return,
|
hash_map::Entry::Occupied(_) => return,
|
||||||
|
@ -463,11 +464,19 @@ impl ExtensionStore {
|
||||||
.get(&url.as_ref(), Default::default(), true)
|
.get(&url.as_ref(), Default::default(), true)
|
||||||
.await
|
.await
|
||||||
.map_err(|err| anyhow!("error downloading extension: {}", err))?;
|
.map_err(|err| anyhow!("error downloading extension: {}", err))?;
|
||||||
|
|
||||||
|
fs.remove_dir(
|
||||||
|
&extension_dir,
|
||||||
|
RemoveOptions {
|
||||||
|
recursive: true,
|
||||||
|
ignore_if_not_exists: true,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let decompressed_bytes = GzipDecoder::new(BufReader::new(response.body_mut()));
|
let decompressed_bytes = GzipDecoder::new(BufReader::new(response.body_mut()));
|
||||||
let archive = Archive::new(decompressed_bytes);
|
let archive = Archive::new(decompressed_bytes);
|
||||||
archive
|
archive.unpack(extension_dir).await?;
|
||||||
.unpack(extensions_dir.join(extension_id.as_ref()))
|
|
||||||
.await?;
|
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.reload(Some(extension_id.clone()), cx)
|
this.reload(Some(extension_id.clone()), cx)
|
||||||
})?
|
})?
|
||||||
|
@ -543,7 +552,7 @@ impl ExtensionStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uninstall_extension(&mut self, extension_id: Arc<str>, cx: &mut ModelContext<Self>) {
|
pub fn uninstall_extension(&mut self, extension_id: Arc<str>, cx: &mut ModelContext<Self>) {
|
||||||
let extensions_dir = self.extensions_dir();
|
let extension_dir = self.installed_dir.join(extension_id.as_ref());
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
|
|
||||||
match self.outstanding_operations.entry(extension_id.clone()) {
|
match self.outstanding_operations.entry(extension_id.clone()) {
|
||||||
|
@ -566,7 +575,7 @@ impl ExtensionStore {
|
||||||
});
|
});
|
||||||
|
|
||||||
fs.remove_dir(
|
fs.remove_dir(
|
||||||
&extensions_dir.join(extension_id.as_ref()),
|
&extension_dir,
|
||||||
RemoveOptions {
|
RemoveOptions {
|
||||||
recursive: true,
|
recursive: true,
|
||||||
ignore_if_not_exists: true,
|
ignore_if_not_exists: true,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue