File: helpers.go

package info (click to toggle)
golang-github-containers-image 5.28.0-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,104 kB
  • sloc: sh: 194; makefile: 73
file content (20 lines) | stat: -rw-r--r-- 927 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package impl

import (
	"github.com/containers/image/v5/internal/private"
	compression "github.com/containers/image/v5/pkg/compression/types"
)

// BlobMatchesRequiredCompression validates if compression is required by the caller while selecting a blob, if it is required
// then function performs a match against the compression requested by the caller and compression of existing blob
// (which can be nil to represent uncompressed or unknown)
func BlobMatchesRequiredCompression(options private.TryReusingBlobOptions, candidateCompression *compression.Algorithm) bool {
	if options.RequiredCompression == nil {
		return true // no requirement imposed
	}
	return candidateCompression != nil && (options.RequiredCompression.Name() == candidateCompression.Name())
}

func OriginalBlobMatchesRequiredCompression(opts private.TryReusingBlobOptions) bool {
	return BlobMatchesRequiredCompression(opts, opts.OriginalCompression)
}