Skip to content

Commit 683af02

Browse files
committed
fix: get around extension update issues in tauri
1 parent 39580f2 commit 683af02

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/extensibility/ExtensionManagerView.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121

2222
/*unittests: ExtensionManager*/
23+
/*global Phoenix*/
2324

2425
define(function (require, exports, module) {
2526

@@ -500,6 +501,7 @@ define(function (require, exports, module) {
500501
*/
501502
ExtensionManagerView.prototype._installUsingDialog = function (id, _isUpdate) {
502503
var entry = this.model.extensions[id];
504+
const self = this;
503505
if (entry && entry.registryInfo) {
504506
const compatInfo = ExtensionManager.getCompatibilityInfo(entry.registryInfo, brackets.metadata.apiVersion),
505507
url = ExtensionManager.getExtensionURL(id, compatInfo.compatibleVersion),
@@ -510,10 +512,26 @@ define(function (require, exports, module) {
510512
// TODO: this should set .done on the returned promise
511513
if (_isUpdate) {
512514
// save to metric id as it is from public extension store.
513-
Metrics.countEvent(Metrics.EVENT_TYPE.EXTENSIONS, "install", id);
514-
InstallExtensionDialog.updateUsingDialog(url).done(ExtensionManager.updateFromDownload);
515-
} else {
516515
Metrics.countEvent(Metrics.EVENT_TYPE.EXTENSIONS, "update", id);
516+
InstallExtensionDialog.updateUsingDialog(url).done((installResult)=>{
517+
if(Phoenix.browser.isTauri) {
518+
// in tauri, due to browser cache for asset urls, updates to extensions will still load old
519+
// extension through the http cache. So we show a restart app for the update to take effect
520+
// message.
521+
entry.installInfo.metadata = entry.registryInfo.metadata;
522+
self.model._getEntry(id).updateAvailable = false;
523+
// this is a hack as we will drop this extnsion manager and move to new one. so this will do.
524+
self.model.trigger("change", id);
525+
Dialogs.showModalDialog(
526+
DefaultDialogs.DIALOG_ID_INFO,
527+
Strings.EXTENSION_UPDATE_RESTART_TITLE,
528+
Strings.EXTENSION_UPDATE_RESTART_MESSAGE
529+
);
530+
}
531+
ExtensionManager.updateFromDownload(installResult);
532+
});
533+
} else {
534+
Metrics.countEvent(Metrics.EVENT_TYPE.EXTENSIONS, "install", id);
517535
InstallExtensionDialog.installUsingDialog(url);
518536
}
519537
}

src/nls/root/strings.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,8 @@ define({
607607
// For NOT_FOUND_ERR, see generic strings above
608608
"EXTENSION_MANAGER_TITLE": "Extension Manager",
609609
"EXTENSION_MANAGER_ERROR_LOAD": "Unable to access the extension registry. Please try again later.",
610+
"EXTENSION_UPDATE_RESTART_TITLE": "Restart To Update",
611+
"EXTENSION_UPDATE_RESTART_MESSAGE": "To load updated extensions, please close all running instances of {APP_NAME} and restart the application.",
610612
"INSTALL_EXTENSION_DRAG": "Drag .zip here or",
611613
"INSTALL_EXTENSION_DROP": "Drop .zip to install",
612614
"INSTALL_EXTENSION_DROP_ERROR": "Install/Update aborted due to the following errors:",

0 commit comments

Comments
 (0)