posix: state follows storage.root; storage.stateDir for a deliberate split (#821) #827
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix-821b"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #821 with options 2 + 3 (decided in review; research in the chat thread, summary below). Supersedes #825.
Behaviour
config.ResolveStateDir()(called in main after config/env/bootstrap are final): every path still at its/data/.cairn/…default is rebased onto the state directory:storage.stateDir/CAIRN_STATE_DIRwhen set (sourcestorage.stateDir);<storage.root>/.cairn(sourcestorage.root) — identical to today with the default root;/data/.cairn(sourcedefault); state documents are in the bucket anyway.tusSpoolDir,peering.stagingDir(cleanup via #826), andbootstrap.json(how Cairn finds the root). Follow the state dir: all state files, pictures, preview cache, audit log, marks ledger.<root>/.cairnis already a reserved root (internal/storage/reserved), so it is invisible on every user surface.moveStateDirmoves state left on/data/.cairnonce (files + avatars/spaceimg/audit/marks), #154 adopt-or-refuse per file; retired copies stay as*.migrated; scratch, bootstrap and foreign files untouched.instance state directory (#821) dir=… from=….Why (research): Vaultwarden (
DATA_FOLDER, everything derives), Gitea (APP_DATA_PATHfromWORK_PATH; a default outside the mounted volume lost data, fixed by a breaking change "the only way … to avoid users losing their data accidently"), Nextcloud (appdata insidedatadirectory, and the opposite demand #32270/#3034 for a deliberate split → ourstateDir), MinIO (.minio.sysbeside the data).Tests:
configtable test (default unchanged, moved root, stateDir wins, explicit paths kept, s3 untouched, look-alike prefix not rewritten);moveStateDir(moves state, retires old, leaves scratch/bootstrap/foreign files, idempotent, refuses on differing copies). Ran the binary withstorage.root=/tmp/…/root: boots (previously it needed a writable/data), state lands inroot/.cairn.Docs: deployment.md "Where state lives" + "Splitting state from files on purpose", upgrade note, refusal list, backups paragraph (also drops the stale "versioning delegated to snapshots"). CHANGELOG v0.6.311.