You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix: create WebDAV parent directories during sync push (#53)
Push was failing on the new file-based backend with 409 Conflicts on note
metadata/page uploads and a 500 Internal Server Error on the welcome
note. Root causes:
- The WebDAV provider had no MKCOL support on the root collection, so
notebook directories never persisted server-side. Subsequent PUTs to
nested paths returned 409 (parent missing).
- NotebookCollection.create_collection minted a fresh note id, so the
slug returned to the caller no longer matched the slug the client
requested — every follow-up PUT 409'd against the lost slug.
- NoteCollection had no create_empty_resource, so PUT to a not-yet-
existing page_N.ink (e.g. a new page during sync) bubbled up as a
permission error.
- NoteMetaFile.get_etag emitted a quoted token, which WsgiDAV's
checked_etag rejects — every PUT to an existing note (the welcome
note in particular) crashed with 500.
- Writer crashes (DB errors, malformed JSON) propagated as bare 500
responses instead of typed DAVErrors.
Fix:
- RootCollection.create_collection materialises a notebook with an id
whose first 8 hex chars match the slug, so MKCOL → PUT round-trips
cleanly. NotebookCollection does the same for notes.
- NoteCollection.create_empty_resource provisions new pages on PUT.
- _NoteMetaWriter migrates the placeholder id to the client's id when
the PUT body declares a different one.
- get_etag now returns a quote-free token; WsgiDAV adds the quotes.
- Writers convert exceptions into DAVError with a useful context_info,
so callers get 400/500 with reasons instead of opaque "500 internal".
- The server bootstraps the "Uncategorized" fallback notebook so the
very first push from a fresh client has a valid parent collection.
- The sync client MKCOLs missing parents on a 409 and retries the PUT
once. Failure messages now include 5xx body snippets.
Tests:
- tests/test_webdav_sync_push.py covers slug parsing, MKCOL idempotency,
PUT into missing parents (live WsgiDAV server), end-to-end sync push,
server bootstrap, and writer error reporting.
https://claude.ai/code/session_011hfnfHGLVJR1aUerZ5sZD6
Co-authored-by: Claude <noreply@anthropic.com>