Creates an empty transaction.
Behaviour settings. createBackups defaults to true, continueOnError to false and maxRetries to 3.
Queues replacing the content of a file, creating parent directories as needed. Execution remembers the previous content if the file exists. Rollback restores it, or deletes the file when it did not exist before.
File to write.
The full new content.
Optionaldescription: string
Overrides the generated description.
Queues creating a new file, with parent directories created as needed. Execution fails if the file already exists. Rollback deletes the file.
File to create.
Content to write.
Optionaldescription: string
Overrides the generated description.
Queues deleting a file. Execution does nothing when the file is already absent, and otherwise remembers its content. Rollback writes that content back, recreating parent directories, if the file had existed.
File to delete.
Optionaldescription: string
Overrides the generated description.
Queues a move of a file. Execution backs up the source when backups are enabled, creates the destination's parent directories and refuses to overwrite an existing destination. Rollback removes the destination and restores the source from the backup.
File to move.
Where to move it to.
Optionaldescription: string
Overrides the generated description.
Clear all planned operations
Runs the queued steps in order, retrying a failing step up to maxRetries times with exponential backoff starting at one second. Unless continueOnError is set, a step that exhausts its retries rolls back every executed step and removes leftover backups. Backups are removed after a successful run.
The outcome. On a rolled-back failure changes is empty.
Lists the queued steps, in order, without executing anything.
One entry per step.
The step's description.
The step's kind, such as file-move.
Get the number of planned operations
Rolls back every executed step in reverse order and forgets them. A step whose rollback throws is reported in a single warning and does not stop the others.
Manages atomic file operations with full rollback capability.
Provides transactional semantics for file system operations, ensuring that either all operations complete successfully or all changes are rolled back. Supports automatic backups and retry logic.
Example
Transactional file operations