[gnome-shell/wip/rstrode/login-screen-extensions: 49/134] extensionDownloader: Make checkForUpdates() check for updates
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/rstrode/login-screen-extensions: 49/134] extensionDownloader: Make checkForUpdates() check for updates
- Date: Thu, 26 Aug 2021 19:30:59 +0000 (UTC)
commit 4fc0bc1d435a7740c5ff84cb33ae4d508619273c
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 | 51 ++++++++------------------------------------
1 file changed, 9 insertions(+), 42 deletions(-)
---
diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js
index 77d013ffbc..66cb13d569 100644
--- a/js/ui/extensionDownloader.js
+++ b/js/ui/extensionDownloader.js
@@ -97,53 +97,20 @@ 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 };
let url = REPOSITORY_URL_DOWNLOAD.format(uuid);
let message = Soup.form_request_new_from_hash('GET', url, params);
- _httpSession.queue_message(message, (session, message) => {
- 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);
- }, (code, message) => {
- log('Error while updating extension %s: %s (%s)'.format(uuid, code, message ? message : ''));
+ _httpSession.queue_message(message, session => {
+ gotExtensionZipFile(session, message, uuid, dir, () => {
+ Main.extensionManager.notifyExtensionUpdate(uuid);
+ }, (code, msg) => {
+ log(`Error while downloading update for extension ${uuid}: ${code} (${msg})`);
});
});
}
@@ -169,7 +136,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]