summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/gzip/gunzip.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2023-05-29 13:47:11 +0100
committerLibravatar GitHub <noreply@github.com>2023-05-29 13:47:11 +0100
commit9ed96bc57083b4261a9e6571d86ec94b1e771e40 (patch)
tree87b6521816ed4d1242f47a731895cd5a8c6cabc6 /vendor/github.com/klauspost/compress/gzip/gunzip.go
parent[bugfix/chore] Inbox post updates (#1821) (diff)
downloadgotosocial-9ed96bc57083b4261a9e6571d86ec94b1e771e40.tar.xz
[chore]: Bump github.com/minio/minio-go/v7 from 7.0.53 to 7.0.55 (#1844)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/klauspost/compress/gzip/gunzip.go')
-rw-r--r--vendor/github.com/klauspost/compress/gzip/gunzip.go29
1 files changed, 27 insertions, 2 deletions
diff --git a/vendor/github.com/klauspost/compress/gzip/gunzip.go b/vendor/github.com/klauspost/compress/gzip/gunzip.go
index 66fe5ddf7..6d630c390 100644
--- a/vendor/github.com/klauspost/compress/gzip/gunzip.go
+++ b/vendor/github.com/klauspost/compress/gzip/gunzip.go
@@ -288,10 +288,35 @@ func (z *Reader) Read(p []byte) (n int, err error) {
return n, nil
}
-// Support the io.WriteTo interface for io.Copy and friends.
+type crcer interface {
+ io.Writer
+ Sum32() uint32
+ Reset()
+}
+type crcUpdater struct {
+ z *Reader
+}
+
+func (c *crcUpdater) Write(p []byte) (int, error) {
+ c.z.digest = crc32.Update(c.z.digest, crc32.IEEETable, p)
+ return len(p), nil
+}
+
+func (c *crcUpdater) Sum32() uint32 {
+ return c.z.digest
+}
+
+func (c *crcUpdater) Reset() {
+ c.z.digest = 0
+}
+
+// WriteTo support the io.WriteTo interface for io.Copy and friends.
func (z *Reader) WriteTo(w io.Writer) (int64, error) {
total := int64(0)
- crcWriter := crc32.NewIEEE()
+ crcWriter := crcer(crc32.NewIEEE())
+ if z.digest != 0 {
+ crcWriter = &crcUpdater{z: z}
+ }
for {
if z.err != nil {
if z.err == io.EOF {