From 4696bfbb80ee98b59caa3a4632eab1bbeb856eb8 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Thu, 23 Aug 2012 22:36:33 -0300 Subject: [PATCH] extensionSystem: Make unloadExtension take an extension object, not a UUID For consistency with loadExtension. https://bugzilla.gnome.org/show_bug.cgi?id=682578 --- js/ui/extensionDownloader.js | 6 +++--- js/ui/extensionSystem.js | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js index 72e1177e8..ea15c26a4 100644 --- a/js/ui/extensionDownloader.js +++ b/js/ui/extensionDownloader.js @@ -60,7 +60,7 @@ function uninstallExtension(uuid) { if (extension.type != ExtensionUtils.ExtensionType.PER_USER) return false; - if (!ExtensionSystem.unloadExtension(uuid)) + if (!ExtensionSystem.unloadExtension(extension)) return false; FileUtils.recursivelyDeleteDir(extension.dir, true); @@ -124,7 +124,7 @@ function updateExtension(uuid) { let oldExtension = ExtensionUtils.extensions[uuid]; let extensionDir = oldExtension.dir; - if (!ExtensionSystem.unloadExtension(uuid)) + if (!ExtensionSystem.unloadExtension(oldExtension)) return; FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir); @@ -135,7 +135,7 @@ function updateExtension(uuid) { try { ExtensionSystem.loadExtension(extension); } catch(e) { - ExtensionSystem.unloadExtension(uuid); + ExtensionSystem.unloadExtension(extension); logError(e, 'Error loading extension %s'.format(uuid)); diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index 38aab59a1..ac4acbb73 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -158,20 +158,16 @@ function loadExtension(extension) { _signals.emit('extension-state-changed', extension); } -function unloadExtension(uuid) { - let extension = ExtensionUtils.extensions[uuid]; - if (!extension) - return false; - +function unloadExtension(extension) { // Try to disable it -- if it's ERROR'd, we can't guarantee that, // but it will be removed on next reboot, and hopefully nothing // broke too much. - disableExtension(uuid); + disableExtension(extension.uuid); extension.state = ExtensionState.UNINSTALLED; _signals.emit('extension-state-changed', extension); - delete ExtensionUtils.extensions[uuid]; + delete ExtensionUtils.extensions[extension.uuid]; return true; }