From 2823c030a44b510a4e7db883f53dc825cb4abc55 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 17 Feb 2022 13:53:03 +0100 Subject: vidhar: ... --- hosts/vidhar/borg/copy.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index e574f2e0..cbd12469 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py @@ -57,26 +57,27 @@ class ToSync: return self def __next__(self): + if to_sync: + return self.to_sync.pop() + while True: try: - if to_sync: - return self.to_sync.pop() - src = read_repo(args.source) dst = read_repo(args.target) - self.to_sync = set() - for entry in src: - if entry['name'] not in {dst_entry['name'] for dst_entry in dst} and not entry['name'].endswith('.checkpoint'): - self.to_sync.add(entry) - - if to_sync: - return self.to_sync.pop() - - raise StopIteration except (subprocess.CalledProcessError, json.decoder.JSONDecodeError) as err: print(err, file=stderr) continue + self.to_sync = set() + for entry in src: + if entry['name'] not in {dst_entry['name'] for dst_entry in dst} and not entry['name'].endswith('.checkpoint'): + self.to_sync.add(entry) + + if to_sync: + return self.to_sync.pop() + + raise StopIteration + def copy_archive(src_repo_path, dst_repo_path, entry): cache_suffix = None with Halo(text=f'Determine archive parameters', **halo_args) as sp: -- cgit v1.2.3