diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 13:51:08 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 13:51:08 +0100 |
commit | 8efca8eff9d8399908dc06432e37642d4b9ce456 (patch) | |
tree | ee5cf6d5791a61412efd15bb62548c251dbbc90a | |
parent | 6de0d6eebc80070c761ea24bf5ef2c0d5f8fcaa2 (diff) | |
download | nixos-8efca8eff9d8399908dc06432e37642d4b9ce456.tar nixos-8efca8eff9d8399908dc06432e37642d4b9ce456.tar.gz nixos-8efca8eff9d8399908dc06432e37642d4b9ce456.tar.bz2 nixos-8efca8eff9d8399908dc06432e37642d4b9ce456.tar.xz nixos-8efca8eff9d8399908dc06432e37642d4b9ce456.zip |
vidhar: ...
-rwxr-xr-x | hosts/vidhar/borg/copy.py | 11 |
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 | ||
53 | class ToSync: | 53 | class 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) |