Skip to content

obsidian/vault-transaction

A reversible, transactional log of vault mutations. Each mutation records how to undo itself; VaultTransaction.rollback reverses the completed steps in reverse order and VaultTransaction.commit finalizes them. It is built on the *Safe vault wrappers so it inherits their case-insensitive / retry / missing-file handling.

A deletion is performed as a soft-delete: the resource is moved aside into a dot-prefixed staging folder (a folder moves its whole subtree in a single rename, so subtree rollback is cheap and faithful). Because Obsidian’s vault file-tree and file watcher ignore any .-prefixed path, staged resources are untracked — they do not churn the metadata cache, flash in the file explorer, or get propagated by sync while the transaction is in flight. The flip side is that vault.* methods cannot see the staging area, so ALL staging I/O goes through App.vault.adapter (mkdir/rename/exists/trashSystem/rmdir). VaultTransaction.commit then trashes the staged resources for real; VaultTransaction.rollback moves them back.

ClassDescription
VaultTransactionA reversible log of vault mutations. Perform mutations through its methods, then call VaultTransaction.commit on success or VaultTransaction.rollback on failure. It is await using-friendly: if neither is called, disposal rolls back.
InterfaceDescription
VaultTransactionConstructorParamsParameters for the VaultTransaction constructor.