summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-08-29 20:20:57 +0300
committerLars Wirzenius <liw@liw.fi>2015-08-29 20:20:57 +0300
commit5ef4654c89983eba9ab9780fe54a550f52a1d2b1 (patch)
tree03a66e6d4f3fec07033678cadea4d86492d4f5bf
parente934763e8788a0aad50b2871b05bbf5182b89f81 (diff)
parent83f034d85c6a787a9c8a7f755b14a97edfb6c32d (diff)
downloadobnam-5ef4654c89983eba9ab9780fe54a550f52a1d2b1.tar.gz
Merge Lukas's changes to unlock if gpg fails
Conflicts: obnamlib/__init__.py
-rw-r--r--obnamlib/__init__.py3
-rw-r--r--obnamlib/plugins/backup_plugin.py7
-rw-r--r--obnamlib/repo_interface.py8
3 files changed, 16 insertions, 2 deletions
diff --git a/obnamlib/__init__.py b/obnamlib/__init__.py
index ff594e8d..06155441 100644
--- a/obnamlib/__init__.py
+++ b/obnamlib/__init__.py
@@ -90,7 +90,8 @@ from .encryption import (
encrypt_with_keyring,
decrypt_with_secret_keys,
SymmetricKeyCache,
- EncryptionError)
+ EncryptionError,
+ GpgError)
from .hooks import (
Hook, MissingFilterError, NoFilterTagError, FilterHook, HookManager)
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py
index d711ab94..7e06ecb8 100644
--- a/obnamlib/plugins/backup_plugin.py
+++ b/obnamlib/plugins/backup_plugin.py
@@ -482,7 +482,12 @@ class BackupPlugin(obnamlib.ObnamPlugin):
self.chunkid_token_map.clear()
def add_client(self, client_name):
- self.repo.lock_client_list()
+ try:
+ self.repo.lock_client_list()
+ except obnamlib.GpgError:
+ self.repo.unlock_client_list()
+ raise
+
if client_name not in self.repo.get_client_names():
tracing.trace('adding new client %s' % client_name)
tracing.trace('client list before adding: %s' %
diff --git a/obnamlib/repo_interface.py b/obnamlib/repo_interface.py
index c618217a..361c33c9 100644
--- a/obnamlib/repo_interface.py
+++ b/obnamlib/repo_interface.py
@@ -394,22 +394,30 @@ class RepositoryInterface(object):
'''
unlockers = []
+ gpg_unlockers = []
try:
if not self.got_client_list_lock():
+ gpg_unlockers.append((self.unlock_client_list, []))
self.lock_client_list()
unlockers.append((self.unlock_client_list, []))
for client_name in self.get_client_names():
if not self.got_client_lock(client_name):
+ gpg_unlockers.append((self.unlock_client, [client_name]))
self.lock_client(client_name)
unlockers.append((self.unlock_client, [client_name]))
if not self.got_chunk_indexes_lock():
+ gpg_unlockers.append((self.unlock_chunk_indexes, []))
self.lock_chunk_indexes()
except obnamlib.LockFail:
for unlocker, args in unlockers:
unlocker(*args)
raise
+ except obnamlib.GpgError:
+ for unlocker, args in gpg_unlockers:
+ unlocker(*args)
+ raise
def unlock_everything(self):
'''Unock every part of the repository to which we hold a lock.