DocShell.Artifact.Transaction (DocShell v0.3.0)

Copy Markdown View Source

Stages a batch of JSON files before replacing any published artifact.

Each output is encoded beside its destination and each existing destination is backed up before publication starts. Returned publication failures restore already replaced files in reverse order. If restoration itself fails, backup paths are retained and returned for recovery instead of deleting the last copy.

Directory locks serialize cooperating builds across BEAM instances. A crashed writer can leave a .doc-shell-build.lock directory and hidden stage/backup files; recover those before removing the lock and rebuilding. This is not a filesystem transaction across power loss. Cache readers continue to validate generation IDs, since individual renames cannot publish multiple files at once. Use dedicated output directories without external writers or symlink aliases.

Summary

Functions

Writes JSON payloads in order, restoring earlier files on publication failure.

Functions

write(outputs)

@spec write([{Path.t(), term()}]) :: :ok | {:error, term()}

Writes JSON payloads in order, restoring earlier files on publication failure.