From 8efca8eff9d8399908dc06432e37642d4b9ce456 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 17 Feb 2022 13:51:08 +0100 Subject: vidhar: ... --- hosts/vidhar/borg/copy.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'hosts') diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index 0d0104ff..155ada7a 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py @@ -51,17 +51,26 @@ def read_repo(path): return res class ToSync: + to_sync = None + def __iter__(self): return self def __next__(self): while True: try: + if to_sync: + return self.to_sync.pop() + src = read_repo(args.source) dst = read_repo(args.target) for entry in src: if entry['name'] not in {dst_entry['name'] for dst_entry in dst} and not entry['name'].endswith('.checkpoint'): - return entry + 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) -- cgit v1.2.3