diff options
| author | 2026-03-30 14:28:13 +0000 | |
|---|---|---|
| committer | 2026-03-30 14:28:13 +0000 | |
| commit | a4eeb727468a178a4de0dfc718828f26740484ac (patch) | |
| tree | 4318d38d49facc80e2e2186f5919fa656be3b31f /object/store/packed/internal/ingest/use.go | |
| parent | object/store/packed: Make store own root, algo, opts (diff) | |
object,store/packed{,/internal/ingest}: Move from format/packfile/ingest
Diffstat (limited to 'object/store/packed/internal/ingest/use.go')
| -rw-r--r-- | object/store/packed/internal/ingest/use.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/object/store/packed/internal/ingest/use.go b/object/store/packed/internal/ingest/use.go new file mode 100644 index 00000000..97f8757a --- /dev/null +++ b/object/store/packed/internal/ingest/use.go @@ -0,0 +1,34 @@ +package ingest + +import ( + "fmt" + "hash/crc32" +) + +// use consumes n unread bytes and updates accounting/checksum state. +func (scanner *streamScanner) use(n int) error { + if n < 0 || n > scanner.n-scanner.off { + return fmt.Errorf("packfile/ingest: invalid consume length %d", n) + } + + if n == 0 { + return nil + } + + chunk := scanner.buf[scanner.off : scanner.off+n] + if scanner.hashEnabled { + _, err := scanner.hash.Write(chunk) + if err != nil { + return err + } + } + + if scanner.inEntryCRC { + scanner.entryCRC = crc32.Update(scanner.entryCRC, crc32.IEEETable, chunk) + } + + scanner.off += n + scanner.consumed += uint64(n) + + return nil +} |
