diff options
author | Lars Wirzenius <liw@liw.fi> | 2012-03-03 17:37:47 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2012-03-03 17:37:47 +0000 |
commit | 1764512865edcef6f15fb2056343dd7bcbdddd47 (patch) | |
tree | 12c8e957d4b750c10b99c44ed28ae8edc7612651 | |
parent | fcc5b72269c3a4e4380359e850486d552e112452 (diff) | |
download | obnam-1764512865edcef6f15fb2056343dd7bcbdddd47.tar.gz |
Fix problem with adding clients during backup
Found a problem where client-1 adds itself to the
repository, and then client-2 does the same, but
client-2 had already read the B-tree into memory
before client-1 added itself, and so when client-2
saved the modified B-tree, it accidentally overwrote
the changes client-1 had made, resulting in no
client-1 in the repository. Oops.
-rw-r--r-- | obnamlib/plugins/backup_plugin.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index d297404f..6751bae3 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -172,8 +172,8 @@ class BackupPlugin(obnamlib.ObnamPlugin): self.repo = self.app.open_repository() self.repo.open_client(client_name) else: - self.repo = self.app.open_repository(create=True) self.add_client(client_name) + self.repo = self.app.open_repository() self.repo.lock_client(client_name) self.repo.lock_shared() @@ -204,11 +204,16 @@ class BackupPlugin(obnamlib.ObnamPlugin): raise def add_client(self, client_name): - if client_name not in self.repo.list_clients(): + repo = self.app.open_repository(create=True) + repo.lock_root() + if client_name not in repo.list_clients(): tracing.trace('adding new client %s' % client_name) - self.repo.lock_root() - self.repo.add_client(client_name) - self.repo.commit_root() + tracing.trace('client list before adding: %s' % + repo.list_clients()) + repo.add_client(client_name) + tracing.trace('client list after adding: %s' % + repo.list_clients()) + repo.commit_root() def compile_exclusion_patterns(self): log = self.app.settings['log'] |