home
·
contact
·
privacy
projects
/
ytplom
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
80e2f66
)
Don't try to sync file missing on both sides.
master
author
Christian Heller
<c.heller@plomlompom.de>
Thu, 28 Nov 2024 22:45:57 +0000
(23:45 +0100)
committer
Christian Heller
<c.heller@plomlompom.de>
Thu, 28 Nov 2024 22:45:57 +0000
(23:45 +0100)
src/sync.py
patch
|
blob
|
history
diff --git
a/src/sync.py
b/src/sync.py
index d0591f74cd80da518b0671402aed826369f716ed..3d6a71245db1eb93a50c149ecd5a16f2071134a8 100755
(executable)
--- a/
src/sync.py
+++ b/
src/sync.py
@@
-89,15
+89,20
@@
def main():
remote_db.commit_close()
scp.put(PATH_DB_REMOTE, PATH_DB)
os_remove(PATH_DB_REMOTE)
remote_db.commit_close()
scp.put(PATH_DB_REMOTE, PATH_DB)
os_remove(PATH_DB_REMOTE)
- for host, port, direction, mover in (
-
(config.remote, config.port_remote, 'local->remote', scp.put
),
-
(config.host, config.port, 'remote->local', scp.ge
t)):
+ missings = []
+
for host, port in ((config.remote, config.port_remote
),
+
(config.host, config.por
t)):
url_missing = f'http://{host}:{port}/{PAGE_NAMES["missing"]}'
with urlopen(url_missing) as response:
url_missing = f'http://{host}:{port}/{PAGE_NAMES["missing"]}'
with urlopen(url_missing) as response:
- missing = json_loads(response.read())
- for path in (path_join(PATH_DOWNLOADS, path) for path in missing):
+ missings += [json_loads(response.read())]
+ for i, direction_mover in enumerate([('local->remote', scp.put),
+ ('remote->local', scp.get)]):
+ direction, mover = direction_mover
+ for path in (p for p in missings[i]
+ if p not in missings[int(not bool(i))]):
+ full_path = path_join(PATH_DOWNLOADS, path)
print(f'SYNC: sending {direction} file {path}')
print(f'SYNC: sending {direction} file {path}')
- mover(
path,
path)
+ mover(
full_path, full_
path)
scp.close()
scp.close()