summaryrefslogtreecommitdiff
path: root/hosts/vidhar/borg
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/vidhar/borg')
-rwxr-xr-xhosts/vidhar/borg/copy.py11
1 files changed, 10 insertions, 1 deletions
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):
51 return res 51 return res
52 52
53class ToSync: 53class ToSync:
54 to_sync = None
55
54 def __iter__(self): 56 def __iter__(self):
55 return self 57 return self
56 58
57 def __next__(self): 59 def __next__(self):
58 while True: 60 while True:
59 try: 61 try:
62 if to_sync:
63 return self.to_sync.pop()
64
60 src = read_repo(args.source) 65 src = read_repo(args.source)
61 dst = read_repo(args.target) 66 dst = read_repo(args.target)
62 for entry in src: 67 for entry in src:
63 if entry['name'] not in {dst_entry['name'] for dst_entry in dst} and not entry['name'].endswith('.checkpoint'): 68 if entry['name'] not in {dst_entry['name'] for dst_entry in dst} and not entry['name'].endswith('.checkpoint'):
64 return entry 69 self.to_sync.add(entry)
70
71 if to_sync:
72 return self.to_sync.pop()
73
65 raise StopIteration 74 raise StopIteration
66 except (subprocess.CalledProcessError, json.decoder.JSONDecodeError) as err: 75 except (subprocess.CalledProcessError, json.decoder.JSONDecodeError) as err:
67 print(err, file=stderr) 76 print(err, file=stderr)