Fix invalid integration plugin installations on macOS
If a Mac user first starts Zotero from the disk image, Zotero shows an error telling them to install the app in Applications, but the integration plugins will have already be registered in extensions.json with paths to the temporary AppTranslocation directory. This meant that the next time the user restarted their computer (or sooner), the AppTranslocation directory would be cleared and the integration plugins would no longer be loaded. This deletes extensions.json if it contains an AppTranslocation path for an extension when the app is started from the disk image, which should prevent this going forward. For existing users experiencing this, it also checks installed extensions at startup for AppTranslocation paths and deletes extensions.json if any appear.
This commit is contained in:
parent
592188bfc5
commit
58c2e38ec2
2 changed files with 32 additions and 0 deletions
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue