mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 02:12:36 +02:00
Fix Settings().set() when setting new setting
Settings().set() would fail if we were trying to set a setting that did not exist before. The reason is because before setting it would try to get the previous value, but though direct key access, which would lead to an exception.
This commit is contained in:
parent
5c86927269
commit
ad16a0e471
1 changed files with 4 additions and 1 deletions
|
@ -47,7 +47,10 @@ class Settings:
|
|||
return self.settings[key]
|
||||
|
||||
def set(self, key: str, val: Any, autosave: bool = False) -> None:
|
||||
old_val = self.get(key)
|
||||
try:
|
||||
old_val = self.get(key)
|
||||
except KeyError:
|
||||
old_val = None
|
||||
self.settings[key] = val
|
||||
if autosave and val != old_val:
|
||||
self.save()
|
||||
|
|
Loading…
Reference in a new issue