Skip to content

Commit

Permalink
Ensure uncompressed layers from c/storage are recorded as uncompresse…
Browse files Browse the repository at this point in the history
…d on upload

When copying an uncompressed layer without modification, arrange
types.BlobInfo.CompressionOperation to be set to types.Decompress,
so that we edit the manifest to use an uncompressed MIME type
(and not, e.g. a zstd:chunked MIME type which might not be representable
in the destination at all).

This is all still gated by the
> 	if srcInfosUpdated || layerDigestsDiffer(srcInfos, destInfos) {
condition in copyLayers, so we don't do these manifest updates
frivolously.

Signed-off-by: Miloslav Trmač <[email protected]>
  • Loading branch information
mtrmac committed Jan 31, 2024
1 parent 5ecc97b commit 046a841
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion copy/compression.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,25 @@ func (ic *imageCopier) bpcPreserveOriginal(_ *sourceStream, detected bpDetectCom
// so that src.UpdatedImage() doesn’t fail; assume that for such blobs
// LayerInfosForCopy() should not be making any changes in the first place.
var bpcOp bpcOperation
var uploadedOp types.LayerCompression
var algorithm *compressiontypes.Algorithm
switch {
case !layerCompressionChangeSupported:
bpcOp = bpcOpPreserveOpaque
uploadedOp = types.PreserveOriginal
algorithm = nil
case detected.isCompressed:
bpcOp = bpcOpPreserveCompressed
uploadedOp = types.PreserveOriginal
algorithm = &detected.format
default:
bpcOp = bpcOpPreserveUncompressed
uploadedOp = types.Decompress
algorithm = nil
}
return &bpCompressionStepData{
operation: bpcOp,
uploadedOperation: types.PreserveOriginal,
uploadedOperation: uploadedOp,
uploadedAlgorithm: algorithm,
srcCompressorName: detected.srcCompressorName,
uploadedCompressorName: detected.srcCompressorName,
Expand Down

0 comments on commit 046a841

Please sign in to comment.