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`.
Unified · Split
| @@ -437,8 +437,9 @@ impl ExtensionStore { · 436 unmodified lines | |||
| 437 | operation: ExtensionOperation, | 437 | operation: ExtensionOperation, |
| 438 | cx: &mut ModelContext<Self>, | 438 | cx: &mut ModelContext<Self>, |
| 439 | ) { | 439 | ) { |
| 440 | let extensions_dir = self.extensions_dir(); | 440 | let extension_dir = self.installed_dir.join(extension_id.as_ref()); |
| 441 | let http_client = self.http_client.clone(); | 441 | let http_client = self.http_client.clone(); |
| 442 | let fs = self.fs.clone(); | ||
| 442 | 443 | ||
| 443 | match self.outstanding_operations.entry(extension_id.clone()) { | 444 | match self.outstanding_operations.entry(extension_id.clone()) { |
| 444 | hash_map::Entry::Occupied(_) => return, | 445 | hash_map::Entry::Occupied(_) => return, |
| @@ -463,11 +464,19 @@ impl ExtensionStore { · 18 unmodified lines | |||
| 463 | .get(&url.as_ref(), Default::default(), true) | 464 | .get(&url.as_ref(), Default::default(), true) |
| 464 | .await | 465 | .await |
| 465 | .map_err(|err| anyhow!("error downloading extension: {}", err))?; | 466 | .map_err(|err| anyhow!("error downloading extension: {}", err))?; |
| 467 | |||
| 468 | fs.remove_dir( | ||
| 469 | &extension_dir, | ||
| 470 | RemoveOptions { | ||
| 471 | recursive: true, | ||
| 472 | ignore_if_not_exists: true, | ||
| 473 | }, | ||
| 474 | ) | ||
| 475 | .await?; | ||
| 476 | |||
| 466 | let decompressed_bytes = GzipDecoder::new(BufReader::new(response.body_mut())); | 477 | let decompressed_bytes = GzipDecoder::new(BufReader::new(response.body_mut())); |
| 467 | let archive = Archive::new(decompressed_bytes); | 478 | let archive = Archive::new(decompressed_bytes); |
| 468 | archive | 479 | archive.unpack(extension_dir).await?; |
| 469 | .unpack(extensions_dir.join(extension_id.as_ref())) | ||
| 470 | .await?; | ||
| 471 | this.update(&mut cx, |this, cx| { | 480 | this.update(&mut cx, |this, cx| { |
| 472 | this.reload(Some(extension_id.clone()), cx) | 481 | this.reload(Some(extension_id.clone()), cx) |
| 473 | })? | 482 | })? |
| @@ -543,7 +552,7 @@ impl ExtensionStore { · 69 unmodified lines | |||
| 543 | } | 552 | } |
| 544 | 553 | ||
| 545 | pub fn uninstall_extension(&mut self, extension_id: Arc<str>, cx: &mut ModelContext<Self>) { | 554 | pub fn uninstall_extension(&mut self, extension_id: Arc<str>, cx: &mut ModelContext<Self>) { |
| 546 | let extensions_dir = self.extensions_dir(); | 555 | let extension_dir = self.installed_dir.join(extension_id.as_ref()); |
| 547 | let fs = self.fs.clone(); | 556 | let fs = self.fs.clone(); |
| 548 | 557 | ||
| 549 | match self.outstanding_operations.entry(extension_id.clone()) { | 558 | match self.outstanding_operations.entry(extension_id.clone()) { |
| @@ -566,7 +575,7 @@ impl ExtensionStore { · 16 unmodified lines | |||
| 566 | }); | 575 | }); |
| 567 | 576 | ||
| 568 | fs.remove_dir( | 577 | fs.remove_dir( |
| 569 | &extensions_dir.join(extension_id.as_ref()), | 578 | &extension_dir, |
| 570 | RemoveOptions { | 579 | RemoveOptions { |
| 571 | recursive: true, | 580 | recursive: true, |
| 572 | ignore_if_not_exists: true, | 581 | ignore_if_not_exists: true, |