diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 19:59:45 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2022-02-17 19:59:45 +0100 |
commit | 29c4f58b15179ec3365fcd27b8fa0db0704535de (patch) | |
tree | 71aa926d21c0d5dcd22ee0cf967403a4ebd211dc /hosts/vidhar/borg | |
parent | 4cf690efccb04e8fe19f232325cffa7fe55d4dd0 (diff) | |
download | nixos-29c4f58b15179ec3365fcd27b8fa0db0704535de.tar nixos-29c4f58b15179ec3365fcd27b8fa0db0704535de.tar.gz nixos-29c4f58b15179ec3365fcd27b8fa0db0704535de.tar.bz2 nixos-29c4f58b15179ec3365fcd27b8fa0db0704535de.tar.xz nixos-29c4f58b15179ec3365fcd27b8fa0db0704535de.zip |
vidhar: ...
Diffstat (limited to 'hosts/vidhar/borg')
-rwxr-xr-x | hosts/vidhar/borg/copy.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/hosts/vidhar/borg/copy.py b/hosts/vidhar/borg/copy.py index 979dc5f4..d58b6060 100755 --- a/hosts/vidhar/borg/copy.py +++ b/hosts/vidhar/borg/copy.py | |||
@@ -27,6 +27,8 @@ from time import sleep | |||
27 | 27 | ||
28 | from halo import Halo | 28 | from halo import Halo |
29 | 29 | ||
30 | from collections import deque | ||
31 | |||
30 | 32 | ||
31 | parser = argparse.ArgumentParser() | 33 | parser = argparse.ArgumentParser() |
32 | parser.add_argument('source', metavar='REPO_OR_ARCHIVE') | 34 | parser.add_argument('source', metavar='REPO_OR_ARCHIVE') |
@@ -51,14 +53,14 @@ def read_repo(path): | |||
51 | return res | 53 | return res |
52 | 54 | ||
53 | class ToSync: | 55 | class ToSync: |
54 | to_sync = [] | 56 | to_sync = deque() |
55 | 57 | ||
56 | def __iter__(self): | 58 | def __iter__(self): |
57 | return self | 59 | return self |
58 | 60 | ||
59 | def __next__(self): | 61 | def __next__(self): |
60 | if self.to_sync: | 62 | if self.to_sync: |
61 | return self.to_sync.pop() | 63 | return self.to_sync.popleft() |
62 | 64 | ||
63 | while True: | 65 | while True: |
64 | try: | 66 | try: |
@@ -68,10 +70,10 @@ class ToSync: | |||
68 | print(err, file=stderr) | 70 | print(err, file=stderr) |
69 | continue | 71 | continue |
70 | 72 | ||
71 | self.to_sync = [entry for entry in src if entry['name'] not in {dst_entry['name'] for dst_entry in dst} and not entry['name'].endswith('.checkpoint')] | 73 | self.to_sync.extend([entry for entry in src if entry['name'] not in {dst_entry['name'] for dst_entry in dst} and not entry['name'].endswith('.checkpoint')]) |
72 | 74 | ||
73 | if self.to_sync: | 75 | if self.to_sync: |
74 | return self.to_sync.pop() | 76 | return self.to_sync.popleft() |
75 | 77 | ||
76 | raise StopIteration | 78 | raise StopIteration |
77 | 79 | ||