After the first sync, magpie reads the backup with the version last seen
(If-None-Match, or If-Modified-Since on a server without ETags) so an
unchanged file costs a 304, not a download. 123pan answers that GET 500
after about 30 seconds (the reporter's curl: a plain GET 200, HEAD 200
with a valid ETag, GET with If-None-Match 500), and every sync failed
with "reading magpie.magpie-backup from the WebDAV server: HTTP 500".
A conditional read answered 5xx is now asked again without the
conditions, and the version is marked NoCondRead (kept in the sync
state), so that server is not asked with a condition again. The ETag the
plain read returns is still sent as If-Match on the write, so a write
from another computer in between is still refused as changed. A plain
read that fails is reported as before.
Changed from the contributor's patch: the mark is set on every version
a plain read returns, not only on the fallback read's. In the patch a
sync that read plainly saved an unmarked version, so every second sync
sent the condition again and waited 30s for the 500. The sync test now
runs three more syncs and checks no condition is sent, and checks that
the merged write carries the plain read's ETag as If-Match.
Run (mote): go test -tags nogui ./internal/davsync/ (ok, 56s);
go vet -tags nogui ./internal/davsync/; gofmt -l (empty).
Broken by hand: with the fallback disabled, both new tests fail with the
reporter's own error ("reading magpie.magpie-backup from the WebDAV
server: HTTP 500"); with the contributor's version of get,
TestSync123panConditionalRead fails ("3 conditional GETs after more
syncs, want 1").
Not tried: a real 123pan account (the fake answers as the reporter's
curl showed); whether 123pan honours If-Match on PUT (writes were never
reached in the report).
Co-authored-by: ggbdpq <ggbdpq@gmail.com>