feat(cso): add verified audits and replayable repair bundles

This commit is contained in:
Garry Tan committed 2026-09-11 04:52:47 +00:00
1 parent 71f6048e8a
commit 100b5b1837
150 files changed
+23595 -2191

No files matched your search

+8 -1
View File
@@ -28,6 +28,8 @@ import * as crypto from 'crypto';
export interface AtomicWriteOpts {
/** File mode for the tmp file at creation (e.g. 0o600). Default: umask. */
mode?: number;
/** Publish only when the target does not already exist. */
noReplace?: boolean;
}
function tmpPathFor(target: string): string {
@@ -47,7 +49,12 @@ export function atomicWriteSync(
} else {
fs.writeFileSync(tmp, data);
}
fs.renameSync(tmp, target);
if (opts.noReplace) {
// Publishing the complete temp inode with link(2) gives atomic
// no-replace semantics; unlink only removes the temporary name.
fs.linkSync(tmp,target);
fs.unlinkSync(tmp);
} else fs.renameSync(tmp, target);
} catch (err) {
try {
fs.unlinkSync(tmp);