Skip to content

Commit

Permalink
Merge pull request #5291 from ktock/generic-diff
Browse files Browse the repository at this point in the history
images: use generic decompressor for calculating DiffID
  • Loading branch information
mxpv committed Mar 31, 2021
2 parents 1b05b60 + c54d92c commit 1c05317
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions images/diffid.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
package images

import (
"compress/gzip"
"context"
"io"

"github.com/containerd/containerd/archive/compression"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/labels"
"github.com/opencontainers/go-digest"
Expand Down Expand Up @@ -55,13 +55,14 @@ func GetDiffID(ctx context.Context, cs content.Store, desc ocispec.Descriptor) (
}
defer ra.Close()
r := content.NewReader(ra)
gzR, err := gzip.NewReader(r)
uR, err := compression.DecompressStream(r)
if err != nil {
return "", err
}
defer uR.Close()
digester := digest.Canonical.Digester()
hashW := digester.Hash()
if _, err := io.Copy(hashW, gzR); err != nil {
if _, err := io.Copy(hashW, uR); err != nil {
return "", err
}
if err := ra.Close(); err != nil {
Expand Down

0 comments on commit 1c05317

Please sign in to comment.