diff --git a/chrome/content/zotero/xpcom/prefs.js b/chrome/content/zotero/xpcom/prefs.js index 3e9aaff3b4..4e9605f463 100644 --- a/chrome/content/zotero/xpcom/prefs.js +++ b/chrome/content/zotero/xpcom/prefs.js @@ -389,6 +389,23 @@ Zotero.Prefs = new function(){ try { let path = OS.Path.fromFileURI(addon.getResourceURI().spec); + // Hack to delete extensions.json for Mac users who first ran Zotero from the + // disk image and ended up with invalid integration plugin paths in + // extensions.json + try { + if (Zotero.isMac && path.includes('AppTranslocation')) { + await OS.File.remove( + OS.Path.join(Zotero.Profile.dir, 'extensions.json'), + { + ignoreAbsent: true + } + ); + } + } + catch (e) { + Zotero.logError(e); + } + // Directory if ((await OS.File.stat(path)).isDir) { let dir = OS.Path.join(path, 'defaults', 'preferences'); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 83f2904e35..9e66e2a825 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1816,6 +1816,21 @@ Services.scriptloader.loadSubScript("resource://zotero/polyfill.js"); Zotero.getString('general.quitApp', Zotero.clientName), null, null, null, {} ); + + // If the integration plugins were installed from the AppTranslocation path, delete + // extensions.json + try { + let file = OS.Path.join(Zotero.Profile.dir, 'extensions.json'); + let json = JSON.parse(Zotero.File.getContents(file)); + if (json.addons.some(x => x.path.includes('AppTranslocation'))) { + file = Zotero.File.pathToFile(file); + file.remove(null); + } + } + catch (e) { + Zotero.logError(e); + } + Zotero.Utilities.Internal.quit(); return false; }