Repository navigation
v0.0.21 — Sync: send only what is missing
v0.0.21 — Sync: send only what is missing
The last of the three. daemon pushes whatever appears; sync pushes what the
other side does not already have, so running it again is cheap enough for cron.
zapsend sync ./out --to gpu-box # push the difference
zapsend sync ./out --to gpu-box --dry-run # say what would move
zapsend sync ./out --to gpu-box --json{"ok":true,"command":"sync","scanned":2,"sent":2,"skipped":0,"bytes":15,
"conflicts":[],"dryRun":false,"dir":"./out","peer":{...}}It has to ask, because LocalSend cannot answer
LocalSend has no "what do you hold?" call, so sync asks
GET /api/zapsend/v1/manifest — a zapsend-only endpoint on the receiver that
lists every file in its folder as path → {size, sha256}. Against a plain
LocalSend app that endpoint is simply not there, and sync says so:
zapsend does not answer /api/zapsend/v1/manifest — it is probably a plain
LocalSend app, which cannot say what it already has; use `zapsend send` instead
An unanswered question is not an empty answer. Assuming "empty" would re-send
the whole folder every night and call it a sync.
The manifest costs a read of the peer's folder (it hashes what it holds), which
is the honest price of not transferring everything. The receive side skips dot
entries and symlinks: .partial bookkeeping and a link out of the tree are not
content.
It will not overwrite, so it refuses instead
LocalSend's upload has no replace. A file that exists on the peer with different
bytes would arrive as report (1).csv, and the two sides would then disagree
forever — every later run would see "different" again and add another copy.
So that case is a conflict: nothing is sent, the path is named, and the run
exits 1.
! a.txt: different content on the peer — LocalSend cannot replace a file, resolve it by hand
Same size is not treated as "same file": the local SHA-256 is compared with the
peer's, because a build that rewrites a report with the same length is exactly
the change worth catching.
Verified
Windows build on WinPE 10.0.26100.1742 against a Linux receiver on this same
version, two runs in a row:
first {"scanned":2,"sent":2,"skipped":0,"bytes":15} exit=0
second {"scanned":2,"sent":0,"skipped":2,"bytes":0} exit=0
--- what the Linux receiver holds:
./a.txt
./sub/b.txt
The subfolder survived the trip. Linux suite: 25 sync checks — manifest
contents, PIN required, tree preserved, identical file not duplicated, second
run sends nothing, differing file becomes a conflict and leaves exactly one copy
on the peer, --dry-run writes nothing — plus 15 unit, 31 compat, 28 json, 25
pull-resume, 29 hosts, 19 pull, 17 resume, 52 fan-out, and the daemon
walkthrough.
The fleet story so far
| command | shape |
|---|---|
send --to a,b |
push a file or folder to several hosts now |
pull --to a,b |
collect from several hosts into dir/<name>/ |
daemon --to a,b |
watch a folder, push each new file to all of them |
sync --to a |
push only the difference, safe to re-run from cron |
Next candidates: sync --to a,b (the same list rule as everywhere else), a
doctor check for the Windows firewall, and running the sync from a systemd
timer on the box that produces the files.