VaultMD / withFileMove
Function: withFileMove()
withFileMove(
from,to,opts?):Promise<void>
Defined in: src/locked-file/move.ts:35
Move a vault file byte-for-byte from from to to, holding BOTH per-file locks (acquired in sorted key order, so opposing moves cannot deadlock). The destination is created exclusively — an occupied path throws rather than being clobbered — and if the source turns out to have changed under us the fresh destination is rolled back, so a failed move never leaves a duplicate.
Emits TWO CommitEvents on success: delete for from, then create for to. There is no dedicated move event — the pair describes the same observable end state.
Parameters
from
Resolved source target — see MoveTarget.
to
Resolved destination target — see MoveTarget.
opts?
Optional onCommit callback and cross-process lock config.
cross?
false | CrossLock
Cross-process lock config, or false (default) for in-process only.
onCommit?
(e) => void | Promise<void>
Optional callback invoked after the move commits, once per event.
Returns
Promise<void>
Throws
MdVaultError VALIDATION_ERROR if both keys are identical (the lock is serializing, not reentrant), NOT_FOUND if the source is absent, ALREADY_EXISTS if the destination is taken, or MTIME_CONFLICT if the source changed under the move.