[gnome-shell] extensions: Consistently handle createExtensionObject() errors



commit 88b1a5d3a098d83f63ca88db9d76993fe7a70e6b
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed May 17 23:51:49 2017 +0200

    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

 js/ui/extensionDownloader.js |    9 +++++----
 js/ui/extensionSystem.js     |    9 ++++++++-
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js
index 6fa0627..452a83a 100644
--- a/js/ui/extensionDownloader.js
+++ b/js/ui/extensionDownloader.js
@@ -130,12 +130,14 @@ function updateExtension(uuid) {
             FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
             FileUtils.recursivelyMoveDir(newExtensionTmpDir, extensionDir);
 
-            let extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, 
ExtensionUtils.ExtensionType.PER_USER);
+            let extension = null;
 
             try {
+                extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, 
ExtensionUtils.ExtensionType.PER_USER);
                 ExtensionSystem.loadExtension(extension);
             } catch(e) {
-                ExtensionSystem.unloadExtension(extension);
+                if (extension)
+                    ExtensionSystem.unloadExtension(extension);
 
                 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);
             }
 
-            let extension = ExtensionUtils.createExtensionObject(uuid, dir, 
ExtensionUtils.ExtensionType.PER_USER);
-
             try {
+                let extension = ExtensionUtils.createExtensionObject(uuid, dir, 
ExtensionUtils.ExtensionType.PER_USER);
                 ExtensionSystem.loadExtension(extension);
             } catch(e) {
                 uninstallExtension(uuid);
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index a4dc29e..fc359e6 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -199,7 +199,14 @@ function reloadExtension(oldExtension) {
     unloadExtension(oldExtension);
 
     // 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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]