You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New src/services/file-safety/safeWriteText.ts: atomic publish primitive — write to a staging temp file in the target directory, fsync, close, then atomic fs.rename over the target; optional backup flag (keeps a .bak copy of the previous contents, matching safeWriteJson semantics); win32 DACL preservation via icacls (rename fallback if it fails); platform injection for testability.
src/utils/safeWriteJson.ts refactored to delegate to it (lock/merge/streaming behavior preserved; existing suite passes unchanged).
DiffViewProvider.saveDirectly (the single funnel for all five write tools) switched from raw fs.writeFile to safeWriteText default options.
Acceptance
No torn writes: readers observe either the old or the new full content (rename is atomic on both POSIX and NTFS)
win32: file ACL preserved after publish (DACL copy); linux: covered via injected platform
safeWriteJson suite green without changes (behavior preserved)
CI green (ubuntu unit-test gate), 100% codecov patch coverage
Status
PR: #1395 open, all CI checks green on head 1a2ade2a5 (ubuntu + windows unit, codecov/patch 100%, CodeRabbit review complete)
Tracking issue for the S3 / A4 PR (branch
feat/atomic-publish-s3; PR to be opened after review).Part of the file-write safety series — plan: easonLiangWorldedtech/Zoo-Code#33, epic: #1375. Item: S3 / A4 — Atomic text publish.
Scope
src/services/file-safety/safeWriteText.ts: atomic publish primitive — write to a staging temp file in the target directory,fsync, close, then atomicfs.renameover the target; optionalbackupflag (keeps a.bakcopy of the previous contents, matchingsafeWriteJsonsemantics); win32 DACL preservation viaicacls(rename fallback if it fails); platform injection for testability.src/utils/safeWriteJson.tsrefactored to delegate to it (lock/merge/streaming behavior preserved; existing suite passes unchanged).DiffViewProvider.saveDirectly(the single funnel for all five write tools) switched from rawfs.writeFiletosafeWriteTextdefault options.Acceptance
safeWriteJsonsuite green without changes (behavior preserved)Status
1a2ade2a5(ubuntu + windows unit, codecov/patch 100%, CodeRabbit review complete)1a2ade2a5(amended after findings: mock-based cross-platform symlink test, DACL save-before/restore-after, fd try/finally, duplicate spec mock removed)