From 18b0565ea636902d692677a4969f6e47bb997fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Tue, 28 Jun 2022 11:19:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20swu:=20Fix=20multiple=20credenti?= =?UTF-8?q?als=20saving?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We make sure to check if any of the credentials we support are contained in the incoming settings data and if so set that, and only that, on our plugin settings, instead of overwriting the stored credentials with just those that changed. See #4540 --- src/octoprint/plugins/softwareupdate/__init__.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/octoprint/plugins/softwareupdate/__init__.py b/src/octoprint/plugins/softwareupdate/__init__.py index 8783720e8..0511eadbb 100644 --- a/src/octoprint/plugins/softwareupdate/__init__.py +++ b/src/octoprint/plugins/softwareupdate/__init__.py @@ -773,7 +773,9 @@ class SoftwareUpdatePlugin( def on_settings_save(self, data): # ~~ plugin settings - for key in self.get_settings_defaults(): + defaults = self.get_settings_defaults() + + for key in defaults: if key in ( "checks", "cache_ttl", @@ -783,6 +785,7 @@ class SoftwareUpdatePlugin( "octoprint_checkout_folder", "octoprint_type", "octoprint_release_channel", + "credentials", ): continue if key in data: @@ -912,6 +915,14 @@ class SoftwareUpdatePlugin( if update_pip_check_config: self._invalidate_version_cache("pip") + # ~~ credentials + + if "credentials" in data: + credentials = data["credentials"] + for key in defaults["credentials"]: + if key in credentials: + self._settings.set(["credentials", key], credentials[key]) + def get_settings_version(self): return 9