fix(safe-write-file): atomic replace via temp file + rename#66
Closed
luojiyin1987 wants to merge 1 commit into
Closed
fix(safe-write-file): atomic replace via temp file + rename#66luojiyin1987 wants to merge 1 commit into
luojiyin1987 wants to merge 1 commit into
Conversation
Replace truncate-then-write with write-to-temp + rename pattern. O_NOFOLLOW symlink protection preserved by opening target first. Explicit chmod after writeFile prevents umask truncating file mode. Restructured try/finally to always close the target handle. Not in scope: fsync, owner/ACL/xattr, cross-file transactions.
8ea2936 to
eef3a88
Compare
Contributor
Author
|
我觉得保留文件创建时间很重要,放弃该pr |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #65
变更
safe-write-file.ts: 将 truncate-then-write 模式替换为 write-to-temp + rename 原子替换。保留O_NOFOLLOW符号链接保护(open()仍为第一步),保留原文件 mode。symlink-security.spec.ts: 新增 2 项测试:preserves original file mode— 写入后 mode 与原始一致leaves no temp file residue on success— 无.lint-md-*.tmp残留不覆盖(明确在范围外)
验证
safe-write-file.ts覆盖率 93.75%