extensions: Consistently handle createExtensionObject() errors
The method may throw an error, for example when metadata.json is missing or cannot be parsed, however we are currently not always handling it. https://bugzilla.gnome.org/show_bug.cgi?id=781728
This commit is contained in:
parent
8d6efde091
commit
88b1a5d3a0
@ -130,11 +130,13 @@ function updateExtension(uuid) {
|
|||||||
FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
|
FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
|
||||||
FileUtils.recursivelyMoveDir(newExtensionTmpDir, extensionDir);
|
FileUtils.recursivelyMoveDir(newExtensionTmpDir, extensionDir);
|
||||||
|
|
||||||
let extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER);
|
let extension = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER);
|
||||||
ExtensionSystem.loadExtension(extension);
|
ExtensionSystem.loadExtension(extension);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
if (extension)
|
||||||
ExtensionSystem.unloadExtension(extension);
|
ExtensionSystem.unloadExtension(extension);
|
||||||
|
|
||||||
logError(e, 'Error loading extension %s'.format(uuid));
|
logError(e, 'Error loading extension %s'.format(uuid));
|
||||||
@ -242,9 +244,8 @@ const InstallExtensionDialog = new Lang.Class({
|
|||||||
global.settings.set_strv(ExtensionSystem.ENABLED_EXTENSIONS_KEY, enabledExtensions);
|
global.settings.set_strv(ExtensionSystem.ENABLED_EXTENSIONS_KEY, enabledExtensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
|
||||||
ExtensionSystem.loadExtension(extension);
|
ExtensionSystem.loadExtension(extension);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
uninstallExtension(uuid);
|
uninstallExtension(uuid);
|
||||||
|
@ -199,7 +199,14 @@ function reloadExtension(oldExtension) {
|
|||||||
unloadExtension(oldExtension);
|
unloadExtension(oldExtension);
|
||||||
|
|
||||||
// Now, recreate the extension and load it.
|
// Now, recreate the extension and load it.
|
||||||
let newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type);
|
let newExtension;
|
||||||
|
try {
|
||||||
|
newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type);
|
||||||
|
} catch(e) {
|
||||||
|
logExtensionError(uuid, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
loadExtension(newExtension);
|
loadExtension(newExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user