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:
parent
9efd5e809f
commit
cbe8e8e72e
3 changed files with 6 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue