From 583833017b49d0800c822fd64e695a3bcc57db40 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Fri, 18 Oct 2019 13:38:51 -0400 Subject: [PATCH] refactor save and encryption check --- torba/torba/client/wallet.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/torba/torba/client/wallet.py b/torba/torba/client/wallet.py index 97b12ef68..db7460d3c 100644 --- a/torba/torba/client/wallet.py +++ b/torba/torba/client/wallet.py @@ -141,16 +141,15 @@ class Wallet: } def save(self): - if not self.is_locked and self.preferences.get(ENCRYPT_ON_DISK, False): + if self.preferences.get(ENCRYPT_ON_DISK, False): if self.encryption_password: - self.storage.write(self.to_dict(encrypt_password=self.encryption_password)) - return - else: + return self.storage.write(self.to_dict(encrypt_password=self.encryption_password)) + elif not self.is_locked: log.warning( "Disk encryption requested but no password available for encryption. " "Saving wallet in an unencrypted state." ) - self.storage.write(self.to_dict()) + return self.storage.write(self.to_dict()) @property def hash(self) -> bytes: