1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-01-03 05:36:19 +00:00

Attempt to unlock secretstorage keyring before returning lock state (#745)

This commit is contained in:
samuel-w 2021-02-14 19:11:11 -06:00 committed by GitHub
parent 9efd5e809f
commit cbe8e8e72e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -68,6 +68,7 @@ def is_primary(self):
@property
def is_unlocked(self):
"""
Try to unlock the keyring.
Returns True if the keyring is open. Return False if it is closed or locked
"""
raise NotImplementedError

View file

@ -41,10 +41,10 @@ def get_result(self, method, args=[]):
@property
def is_unlocked(self):
self.get_handle()
self.try_unlock()
return self.handle > 0
def get_handle(self):
def try_unlock(self):
wallet_name = self.get_result("networkWallet")
wId = QVariant(0)
wId.convert(4)

View file

@ -46,7 +46,9 @@ def get_password(self, service, repo_url):
def is_unlocked(self):
try:
collection = secretstorage.get_default_collection(self.connection)
return not collection.is_locked()
if collection.is_locked(): # Prompt for unlock
collection.unlock()
return not collection.is_locked() # In case of denial
except secretstorage.exceptions.SecretServiceNotAvailableException:
logger.debug('SecretStorage is closed.')
return False