Skip to content

Commit

Permalink
copy: skip reusingblob if compression algorithm is different
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed Nov 25, 2020
1 parent 1c5c278 commit 232a5b6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,12 +1065,18 @@ func (ic *imageCopier) copyLayer(ctx context.Context, srcInfo types.BlobInfo, to
// Diffs are needed if we are encrypting an image or trying to decrypt an image
diffIDIsNeeded := ic.diffIDsAreNeeded && cachedDiffID == "" || toEncrypt || (isOciEncrypted(srcInfo.MediaType) && ic.c.ociDecryptConfig != nil)

srcAlgo := ""
if srcInfo.CompressionAlgorithm != nil {
srcAlgo = srcInfo.CompressionAlgorithm.Name()
}
// If we already have the blob, and we don't need to compute the diffID, then we don't need to read it from the source.
if !diffIDIsNeeded {
mustRecompress := srcInfo.CompressionOperation != types.PreserveOriginal || srcAlgo != ic.c.compressionFormat.Name()
if !diffIDIsNeeded && !mustRecompress {
reused, blobInfo, err := ic.c.dest.TryReusingBlob(ctx, srcInfo, ic.c.blobInfoCache, ic.canSubstituteBlobs)
if err != nil {
return types.BlobInfo{}, "", errors.Wrapf(err, "Error trying to reuse blob %s at destination", srcInfo.Digest)
}

if reused {
logrus.Debugf("Skipping blob %s (already present):", srcInfo.Digest)
bar := ic.c.createProgressBar(pool, srcInfo, "blob", "skipped: already exists")
Expand Down

0 comments on commit 232a5b6

Please sign in to comment.