Expand description
Writing the user’s files in place: atomic replacement and per-file locks.
Every server endpoint that rewrites an existing note — the editor, task toggles, flashcard reviews, moves and the link rewriting a move triggers — goes through here, so they agree on two things:
- Atomic replacement (
atomic_write, implemented bymbr_core::vault::LocalVaultand re-exported here): a temp file with a name of its own, beside the target, renamed over it, carrying the target’s permissions. - Serialization (
FileWriteLocks): a read-patch-write cycle on one file excludes every other one on the same file, so no write is silently overwritten by a second writer that read the older text.
Knows nothing about HTTP; callers map std::io::Error themselves.
Structs§
- File
Write Locks - One async mutex per file, for code that reads a file, patches it and writes it back.
Functions§
- atomic_
write - Atomically writes
bytestopath(temp file in the same dir + rename). - create_
unique_ temp_ file - Creates a fresh temp file beside a write target, for a write-then-rename.