fix(nwsync): hash through a section reader, pin the encoder claim (#76)
ci / ci (pull_request) Successful in 3m30s
ci / ci (pull_request) Successful in 3m30s
Review follow-ups. checkArtifactKey drained the *os.File to EOF, so the file offset was left at the end; correct only because everything after it uses ReadAt. Hash a section reader instead, so no later sequential read can silently see nothing. The zstd concurrency comment claimed byte-identical output but nothing asserted it, so add the test. erf.Read now says outright that Data must not be mutated, since payloads alias one buffer. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -389,8 +389,9 @@ func ReadPayload(r io.ReaderAt, entry IndexEntry) ([]byte, error) {
|
||||
}
|
||||
|
||||
// Read materialises a whole archive. Payloads are subslices of the buffer the
|
||||
// archive was read into, so nothing is copied twice; callers that only need one
|
||||
// resource at a time should use ReadIndex instead.
|
||||
// archive was read into, so nothing is copied twice: a caller must not mutate
|
||||
// Data. Callers that only need one resource at a time should use ReadIndex
|
||||
// instead, which never holds the archive at all.
|
||||
func Read(r io.Reader) (Archive, error) {
|
||||
data, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user