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 | 437 | operation: ExtensionOperation, |
| 438 | 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 | 441 | let http_client = self.http_client.clone(); |
| 442 | + let fs = self.fs.clone(); | |
| 442 | 443 | |
| 443 | 444 | match self.outstanding_operations.entry(extension_id.clone()) { |
| 444 | 445 | hash_map::Entry::Occupied(_) => return, |
| @@ -463,11 +464,19 @@ impl ExtensionStore { · 18 unmodified lines | ||
| 463 | 464 | .get(&url.as_ref(), Default::default(), true) |
| 464 | 465 | .await |
| 465 | 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 | 477 | let decompressed_bytes = GzipDecoder::new(BufReader::new(response.body_mut())); |
| 467 | 478 | let archive = Archive::new(decompressed_bytes); |
| 468 | − archive | |
| 469 | − .unpack(extensions_dir.join(extension_id.as_ref())) | |
| 470 | − .await?; | |
| 479 | + archive.unpack(extension_dir).await?; | |
| 471 | 480 | this.update(&mut cx, |this, cx| { |
| 472 | 481 | this.reload(Some(extension_id.clone()), cx) |
| 473 | 482 | })? |
| @@ -543,7 +552,7 @@ impl ExtensionStore { · 69 unmodified lines | ||
| 543 | 552 | } |
| 544 | 553 | |
| 545 | 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 | 556 | let fs = self.fs.clone(); |
| 548 | 557 | |
| 549 | 558 | match self.outstanding_operations.entry(extension_id.clone()) { |
| @@ -566,7 +575,7 @@ impl ExtensionStore { · 16 unmodified lines | ||
| 566 | 575 | }); |
| 567 | 576 | |
| 568 | 577 | fs.remove_dir( |
| 569 | − &extensions_dir.join(extension_id.as_ref()), | |
| 578 | + &extension_dir, | |
| 570 | 579 | RemoveOptions { |
| 571 | 580 | recursive: true, |
| 572 | 581 | ignore_if_not_exists: true, |