[gnome-shell] extensionDownloader: Make checkForUpdates() check for updates
- From: verdre <jonasd src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensionDownloader: Make checkForUpdates() check for updates
- Date: Thu, 30 Jan 2020 14:06:03 +0000 (UTC)
commit 9c785ca6b660c38252548b6c7d51cfb9c68e0bbf
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Jan 22 15:07:45 2020 +0100
extensionDownloader: Make checkForUpdates() check for updates
Currently the method installs updates instead of merely checking for
them (or it would do, if it actually worked).
This is not just surprising considering the method name, the whole idea
of live updates is problematic and will not work properly more often
than not:
- imports are cached, so any local modules will stay at their
original version until a shell restart
- GTypes cannot be unregistered
So change the method to only download available updates, and set the
extensions' hasUpdate state accordingly.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/945
js/ui/extensionDownloader.js | 50 +++++++-------------------------------------
1 file changed, 8 insertions(+), 42 deletions(-)
---
diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js
index 768b5dcc63..2ae64ea44d 100644
--- a/js/ui/extensionDownloader.js
+++ b/js/ui/extensionDownloader.js
@@ -1,6 +1,5 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
-/* exported init, installExtension, uninstallExtension,
- checkForUpdates, updateExtension */
+/* exported init, installExtension, uninstallExtension, checkForUpdates */
const { Clutter, Gio, GLib, GObject, Soup } = imports.gi;
@@ -100,13 +99,9 @@ function gotExtensionZipFile(session, message, uuid, dir, callback, errback) {
});
}
-function updateExtension(uuid) {
- // This gets a bit tricky. We want the update to be seamless -
- // if we have any error during downloading or extracting, we
- // want to not unload the current version.
-
- let oldExtensionTmpDir = GLib.Dir.make_tmp('XXXXXX-shell-extension');
- let newExtensionTmpDir = GLib.Dir.make_tmp('XXXXXX-shell-extension');
+function downloadExtensionUpdate(uuid) {
+ let dir = Gio.File.new_for_path(
+ GLib.build_filenamev([global.userdatadir, 'extension-updates', uuid]));
let params = { shell_version: Config.PACKAGE_VERSION };
@@ -114,39 +109,10 @@ function updateExtension(uuid) {
let message = Soup.form_request_new_from_hash('GET', url, params);
_httpSession.queue_message(message, session => {
- gotExtensionZipFile(session, message, uuid, newExtensionTmpDir, () => {
- let oldExtension = Main.extensionManager.lookup(uuid);
- let extensionDir = oldExtension.dir;
-
- if (!Main.extensionManager.unloadExtension(oldExtension))
- return;
-
- FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
- FileUtils.recursivelyMoveDir(newExtensionTmpDir, extensionDir);
-
- let extension = null;
-
- try {
- extension = Main.extensionManager.createExtensionObject(uuid, extensionDir,
ExtensionUtils.ExtensionType.PER_USER);
- Main.extensionManager.loadExtension(extension);
- } catch (e) {
- if (extension)
- Main.extensionManager.unloadExtension(extension);
-
- logError(e, 'Error loading extension %s'.format(uuid));
-
- FileUtils.recursivelyDeleteDir(extensionDir, false);
- FileUtils.recursivelyMoveDir(oldExtensionTmpDir, extensionDir);
-
- // Restore what was there before. We can't do much if we
- // fail here.
- Main.extensionManager.loadExtension(oldExtension);
- return;
- }
-
- FileUtils.recursivelyDeleteDir(oldExtensionTmpDir, true);
+ gotExtensionZipFile(session, message, uuid, dir, () => {
+ Main.extensionManager.notifyExtensionUpdate(uuid);
}, (code, msg) => {
- log(`Error while updating extension ${uuid}: ${code} (${msg})`);
+ log(`Error while downloading update for extension ${uuid}: ${code} (${msg})`);
});
});
}
@@ -172,7 +138,7 @@ function checkForUpdates() {
if (operation == 'blacklist')
uninstallExtension(uuid);
else if (operation == 'upgrade' || operation == 'downgrade')
- updateExtension(uuid);
+ downloadExtensionUpdate(uuid);
}
});
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]