vault-link/sync-server
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-19 17:05:50 +01:00
..
src Add new data model 2026-09-19 17:05:50 +01:00
.dockerignore Extract reconcile (#85) 2025-07-13 11:06:42 +01:00
.env Extract reconcile (#85) 2025-07-13 11:06:42 +01:00
build.rs Migrate server to CAS only 2026-09-16 10:36:20 +01:00
Cargo.lock Update deps 2026-09-19 15:53:30 +01:00
Cargo.toml Update deps 2026-09-19 15:53:30 +01:00
config-e2e.yml Move log level to config file 2025-12-07 16:42:23 +00:00
Dockerfile Bump rust from 1.90-slim-trixie to 1.91-slim-trixie in /sync-server (#156) 2025-11-02 17:52:18 +00:00
README.md Migrate server to CAS only 2026-09-16 10:36:20 +01:00
rust-toolchain.toml Apply editorconfig 2025-12-07 16:42:23 +00:00

Sync server

Document pushes (API v3)

The server stores immutable document versions. One compare-and-swap endpoint, PUT /vaults/:vault_id/documents/:document_id, handles every mutation. The client generates the document UUID; the JSON body contains:

  • requestId: a UUID identifying this exact push.
  • parentVersionId: null to create an absent document, otherwise its base version.
  • relativePath: the desired filename.
  • content: { "type": "Snapshot", "value": "<base64>" }, { "type": "Diff", "value": [3, "inserted text", -2] }, or { "type": "Delete" }.

All pushes return one of:

  • Accepted: version metadata for the exact snapshot committed. A retry with the same request ID returns the original acknowledgement, even after a restart or subsequent updates. Clients must persist the ID with the unchanged request. A payload fingerprint rejects reusing that ID for a different mutation.
  • StaleBase: the current version, including contentBase64. Nothing was written; the client merges locally and submits a new push with a new request ID.

The base check, path allocation, new version, and durable acknowledgement share one SQLite write transaction. A deleted document stays deleted; recreating a file uses a new document ID. Occupied paths receive an available numbered filename. Text updates accept reconcile-text transport diffs against the base version; the server only reconstructs snapshots and never merges concurrent edits.

Snapshot requests use base64, adding roughly one third to the raw file size. Server and reverse-proxy request limits apply to the encoded JSON body.

API v3 uses a fresh schema. Update clients together with the server and initialise new vault databases; compatibility with previous releases is not supported.

Creating/resetting the Database for development

rm -rf db.sqlite*
sqlx database create --database-url sqlite://db.sqlite3
sqlx migrate run --source src/app_state/database/migrations --database-url sqlite://db.sqlite3
cargo sqlx prepare --workspace

Updating the DB schema through a migration

sqlx migrate add --source src/app_state/database/migrations <name>
sqlx migrate run --source src/app_state/database/migrations --database-url sqlite://db.sqlite3