diff options
| author | 2026-03-30 14:28:13 +0000 | |
|---|---|---|
| committer | 2026-03-30 14:28:13 +0000 | |
| commit | a4eeb727468a178a4de0dfc718828f26740484ac (patch) | |
| tree | 4318d38d49facc80e2e2186f5919fa656be3b31f /format/packfile/ingest/trailer.go | |
| parent | object/store/packed: Make store own root, algo, opts (diff) | |
| signature | No signature | |
object,store/packed{,/internal/ingest}: Move from format/packfile/ingest
Diffstat (limited to 'format/packfile/ingest/trailer.go')
| -rw-r--r-- | format/packfile/ingest/trailer.go | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/format/packfile/ingest/trailer.go b/format/packfile/ingest/trailer.go deleted file mode 100644 index 7a26a8f2..00000000 --- a/format/packfile/ingest/trailer.go +++ /dev/null @@ -1,58 +0,0 @@ -package ingest - -import ( - "bytes" - "errors" - "fmt" - "io" -) - -// finishAndFlushTrailer reads trailer hash bytes, verifies trailer checksum, -// and optionally requires the source stream to hit EOF afterward. -func (scanner *streamScanner) finishAndFlushTrailer(requireTrailingEOF bool) error { - if scanner.hashSize <= 0 { - return fmt.Errorf("packfile/ingest: invalid hash size") - } - - trailer := make([]byte, scanner.hashSize) - - scanner.hashEnabled = false - - err := scanner.readFull(trailer) - if err != nil { - return &PackTrailerMismatchError{} - } - - scanner.packTrailer = append(scanner.packTrailer[:0], trailer...) - - if scanner.n-scanner.off > 0 { - return fmt.Errorf("packfile/ingest: pack has trailing garbage") - } - - if !requireTrailingEOF { - computed := scanner.hash.Sum(nil) - if !bytes.Equal(computed, trailer) { - return &PackTrailerMismatchError{} - } - - return nil - } - - var probe [1]byte - - n, err := scanner.Read(probe[:]) - if n > 0 || err == nil { - return fmt.Errorf("packfile/ingest: pack has trailing garbage") - } - - if !errors.Is(err, io.EOF) { - return err - } - - computed := scanner.hash.Sum(nil) - if !bytes.Equal(computed, trailer) { - return &PackTrailerMismatchError{} - } - - return nil -} |
