summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhosts/vidhar/borg/copy.py10
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
28from halo import Halo 28from halo import Halo
29 29
30from collections import deque
31
30 32
31parser = argparse.ArgumentParser() 33parser = argparse.ArgumentParser()
32parser.add_argument('source', metavar='REPO_OR_ARCHIVE') 34parser.add_argument('source', metavar='REPO_OR_ARCHIVE')
@@ -51,14 +53,14 @@ def read_repo(path):
51 return res 53 return res
52 54
53class ToSync: 55class 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