Skip to content

refactor(release-plan): stream hashes and write SHA256SUMS atomically - #356

Open
DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:refactor/release-plan-atomic-streamed
Open

DeryFerd wants to merge 1 commit into
qybaihe:mainfrom
DeryFerd:refactor/release-plan-atomic-streamed

Conversation

@DeryFerd

@DeryFerd DeryFerd commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

packDualReleaseTarballs hashed both tarballs with a whole-file readFileSync and wrote SHA256SUMS.txt in place. A crash or a full disk between the two hashes and the write could leave a partial checksum file next to complete tarballs, and large tarballs were buffered only to compute a digest.

What changed

  • Tarball hashing uses a 1 MiB readSync loop, so the digest no longer requires the whole archive in memory.
  • SHA256SUMS.txt is written to a same-directory temp file, then renamed into place. A failure removes the temp file and leaves any previous checksum file untouched.
  • tests/release-plan-packaging.test.ts runs the real pack path on a temporary package, checks both digests independently, checks both lines in SHA256SUMS.txt, and asserts that no .bla-tmp- file is left behind.

Compatibility

The checksum file name, format and digests are unchanged. The temp name is internal. The function signature and the returned DualPackResult are unchanged.

Verification

  • npx vitest run tests/release-plan-packaging.test.ts passes.
  • npx tsc --noEmit is clean.

Hash the packed tarballs in 1 MiB chunks instead of loading them whole, and write the checksum file through a same-directory temp file plus rename so a crash cannot leave a partial SHA256SUMS.txt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant