feat(download): durable atomic writer and per-chunk progress hook (closes #39) #56

Merged
clawbot merged 1 commits from issue-39-atomic-fsync-progress into next 2026-09-22 12:01:06 +02:00
1 Commits
Author SHA1 Message Date
sneak 8e28c83210 feat(download): durable atomic writer and per-chunk progress hook (closes #39)
check / check (push) Successful in 26s
Add fsync to the atomic writer and export it, and give the download
functions an optional per-chunk progress hook.

writeAtomic now fsyncs the staged temp file before the rename and fsyncs
the containing directory after it, so a power cut immediately after the
write cannot resurrect an empty renamed file. It is exported so the
metadata store can reuse the same durable write.

downloadFile and downloadThumbnail take an optional onProgress(bytesDone)
callback that fires within streamDecrypt as decrypted plaintext
accumulates; its values are non-decreasing and the last equals
bytesWritten. Absent, the callback is a no-op. Whole-file buffering,
retry semantics, and the TAG_FINAL truncation checks are unchanged.

Covers the fsync durability gap of #22 (area 1) only; orphan reaping,
symlink/mode docs, and the remaining test coverage there stay for a
later unit, so #22 is referenced, not closed.

Model: opus-4-8
2026-09-22 09:35:32 +00:00