Commit Graph
6 Commits
Author SHA1 Message Date
ggbdpq cc22efebb7 davsync: a 403 on the write names the folder it went to, and a full quota (#4927)
The error for a write the server refused, with the address's folder
listing fine, said the account couldn't write in that folder (/dav) -
but the write went to magpie's own folder inside it, and the listing
never proved anything about writing. On 坚果云 (Nutstore) the refusal
is usually the free tier's upload quota used up, which answers 403 on
a PUT with everything else fine (#4927), so the old text sent the user
to check a thing they can't check.

The error now looks at magpie's own folder first: there, the server
refused to change files in it, and the text says so and mentions the
quota; missing, the server refused to have magpie make it, and the
text says to make the folder by hand, or put an existing folder in
the address.

Review, changed from ggbdpq's patch: the folder is named with
path.Join(dir, folder). The patch's dir+"/"+folder said "//magpie"
for an address with no folder of its own (dir "/"). The test now
covers that address too. Broken by hand at the reviewed head:
dir+"/"+folder back, TestDAVWriteRefused red; dav.go reverted to its
parent, red; restored, green.

Run at the pushed tree (this stack of nine on origin/main 3c2dceb34),
on mote (macOS arm64, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/catalog/...
  ./internal/plugin/... ./internal/davsync/... ./internal/gateway/...:
  catalog, plugin and davsync ok; gateway red on one test only,
  TestCodexPoolSaysTheClientsVersion, the open #4807 (another test's
  Codex identity reaches it in a full package run). It passes run
  alone at this tree, 3 of 3.
- go vet ./... (darwin); GOOS=linux and GOOS=windows go vet -tags
  nogui ./...: ok. gofmt -l on every tracked .go file: clean.
- The hand breaks above ran on this stack before its rebase onto
  3c2dceb34. That commit changed member.go only, nothing these tests
  reach.
Not tried: the GUI suite, since no GUI file changed. Windows and Linux
test runs (the Claude bridge tests use a shell fake and skip on
Windows). No real vendor, Claude Code or network was used; every
case runs against fakes.

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-03 07:43:18 +08:00
尔立andClaude Code 93a1e3e7fc fix(davsync): detect a WebDAV write the server kept short (#531)
Relays and tunnels cut long uploads short. Over a Cloudflare Tunnel
with a 3MB write this came up 2 of 3 times, and each time the client
saw it happen: the relay answered 502 or 423, which the sync reports
as itself. The quiet shape is a server that answers 2xx with half the
file on disk: every later sync then reads the half and fails as "not
a magpie backup", with no way to tell what actually went wrong.

A write is now looked at after it lands: a HEAD read of the backup is
compared with the size sent, a short write is retried over the version
the short one made (its ETag, from the PUT's answer or the HEAD's), and
after three tries reported as itself. A HEAD that can't be done — an
error, a 429 or 503, a non-200 — leaves the write unchecked: it landed
either way. Servers without HEAD check as before.

Co-authored-by: Claude Code <noreply@anthropic.com>
2026-10-02 16:42:37 +08:00
yetone 7ab91961d2 davsync: an unchanged file on the server costs a request, not a download (Crispin on Discord: 是不是Magpie后台一直在自动同步,导致被坚果云给限制了) — every 3 minutes sync read the whole sealed file even when nothing had changed, and 坚果云's free plan caps monthly downloads and requests per 30 minutes. The sync state now keeps the server's version beside its hash (its ETag, or a Last-Modified at least a second older than the server's Date, so a write in that same second can't go unseen), from the read or from the ETag a write answers with (none said: the next sync reads in full, as before); the next read sends If-None-Match (or If-Modified-Since) and a 304 with nothing changed here ends the sync, while a change here merges with a copy of the server's file kept beside sync-state.json (sync-server.magpie-backup, 0600, checked against the hash; gone or different, the file is read again), so it isn't read twice. A server that ignores the condition sends the file and syncs exactly as today. S3 does the same with If-None-Match on GetObject, signed with the rest (the fake S3 checks every signature). A 429 or 503 (S3's SlowDown) now says the server is limiting how often magpie may reach it, and Run waits as long as Retry-After says (up to 6 h) or else doubles from 6 up to 30 minutes, back to 3 after a sync that goes through; log de-dup is kept, as the message doesn't carry the wait. The 403 paths (there, forbidden) only run when the server answers 403, so a working setup costs one conditional GET per cycle. TestSyncUnchangedIsNotRead (ETag, ETag not on PUT, Last-Modified: three unchanged cycles read 0 bytes, a server change is read once and merged, a change here is pushed without a read, a missing copy is read again), TestSyncRateLimited and TestS3Unchanged fail without the change (with the conditions dropped: 3 full reads of 1932 bytes, 'HTTP 429' with no backoff, unconditional S3 GETs); TestSyncIgnoringConditions guards servers without conditional reads. go vet ./internal/..., go build -tags nogui ./... (darwin, GOOS=linux), GOOS=windows go build ./..., go test -tags nogui ./internal/davsync/ ./internal/gui/ pass. 2026-10-02 11:08:14 +08:00
yetone 2b2a7bf83f sync: a WebDAV server that answers 403 for what isn't there (a Synology, PROPFIND too) no longer fails the first sync as if the account couldn't write in the folder — magpie's own folder in it is looked for, and when it isn't there a 403 to reading the backup is no backup yet and one to writing it is made as a 404 is 2026-09-28 10:51:05 +08:00
yetone c6dc08e105 sync: an address at OpenList's or Alist's /dav/ says to go into one of its storages, naming them — the list of storages there takes no folder (MKCOL 405, as if it were there) and no file (PUT 404), so a first sync failed with a bare HTTP 404; a folder in the address that isn't there says so. Tried on OpenList 4.2.6 2026-09-28 10:10:03 +08:00
yetone 920bc04d48 sync: a WebDAV 403 says why rather than blaming the password — a folder in the address the server hasn't got (a Synology answers 403 for a shared folder not made), one the account may only read, or one it may not use, told apart by looking at that folder; only a 401 is the user name or password 2026-09-28 09:31:10 +08:00