diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js index 90fd9abc6..690b1c035 100644 --- a/js/extensionPrefs/main.js +++ b/js/extensionPrefs/main.js @@ -207,20 +207,9 @@ const Application = new Lang.Class({ finder.scanExtensions(); }, - _extensionFound: function(signals, uuid, dir, type) { - if (ExtensionUtils.extensions[uuid] !== undefined) - return; - - let extension; - try { - extension = ExtensionUtils.createExtensionObject(uuid, dir, type); - } catch(e) { - logError(e, 'Could not create extensions object'); - return; - } - + _extensionFound: function(signals, extension) { let iter = this._model.append(); - this._model.set(iter, [0, 1], [uuid, extension.metadata.name]); + this._model.set(iter, [0, 1], [extension.uuid, extension.metadata.name]); this._extensionIters[uuid] = iter; }, diff --git a/js/misc/extensionUtils.js b/js/misc/extensionUtils.js index 3eaa1b9e4..cec24ba1d 100644 --- a/js/misc/extensionUtils.js +++ b/js/misc/extensionUtils.js @@ -171,7 +171,14 @@ const ExtensionFinder = new Lang.Class({ continue; let uuid = info.get_name(); let extensionDir = dir.get_child(uuid); - this.emit('extension-found', uuid, extensionDir, type); + + let existing = extensions[uuid]; + if (existing) { + log('Extension %s already installed in %s. %s will not be loaded'.format(uuid, existing.path, extensionDir.get_path())); + continue; + } + let extension = createExtensionObject(uuid, extensionDir, type); + this.emit('extension-found', extension); } fileEnum.close(null); }, diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index 902ecb691..6dde4665f 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -129,35 +129,21 @@ function logExtensionError(uuid, message, state) { state: state }); } -function loadExtension(dir, type, enabled) { - let uuid = dir.get_basename(); - let extension; - - if (ExtensionUtils.extensions[uuid] != undefined) { - log('Extension "%s" is already loaded'.format(uuid)); - return; - } - - try { - extension = ExtensionUtils.createExtensionObject(uuid, dir, type); - } catch(e) { - logExtensionError(uuid, e.message); - return; - } - +function loadExtension(extension) { // Default to error, we set success as the last step extension.state = ExtensionState.ERROR; if (ExtensionUtils.isOutOfDate(extension)) { - logExtensionError(uuid, 'extension is not compatible with current GNOME Shell and/or GJS version', ExtensionState.OUT_OF_DATE); + logExtensionError(extension.uuid, 'extension is not compatible with current GNOME Shell and/or GJS version', ExtensionState.OUT_OF_DATE); extension.state = ExtensionState.OUT_OF_DATE; return; } + let enabled = enabledExtensions.indexOf(extension.uuid) != -1; if (enabled) { - initExtension(uuid); + initExtension(extension.uuid); if (extension.state == ExtensionState.DISABLED) - enableExtension(uuid); + enableExtension(extension.uuid); } else { extension.state = ExtensionState.INITIALIZED; } @@ -263,9 +249,8 @@ function init() { function loadExtensions() { let finder = new ExtensionUtils.ExtensionFinder(); - finder.connect('extension-found', function(signals, uuid, dir, type) { - let enabled = enabledExtensions.indexOf(uuid) != -1; - loadExtension(dir, type, enabled); + finder.connect('extension-found', function(signals, extension) { + loadExtension(extension); }); finder.scanExtensions(); }