From f9a1846ca23f462b0e5d7e8f111c7ab322c53b44 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 24 Jan 2022 16:34:56 +0100 Subject: [PATCH] distribution: PushLayer.Size(): remove unused error return None of the implementations returned an error for this function, so removing it. Signed-off-by: Sebastiaan van Stijn --- distribution/config.go | 6 +++--- distribution/push_v2.go | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/distribution/config.go b/distribution/config.go index 43cb674a87..3cd2f190ff 100644 --- a/distribution/config.go +++ b/distribution/config.go @@ -102,7 +102,7 @@ type PushLayer interface { DiffID() layer.DiffID Parent() PushLayer Open() (io.ReadCloser, error) - Size() (int64, error) + Size() int64 MediaType() string Release() } @@ -229,8 +229,8 @@ func (l *storeLayer) Open() (io.ReadCloser, error) { return l.Layer.TarStream() } -func (l *storeLayer) Size() (int64, error) { - return l.Layer.DiffSize(), nil +func (l *storeLayer) Size() int64 { + return l.Layer.DiffSize() } func (l *storeLayer) MediaType() string { diff --git a/distribution/push_v2.go b/distribution/push_v2.go index 60171de773..4a58527c8b 100644 --- a/distribution/push_v2.go +++ b/distribution/push_v2.go @@ -451,9 +451,7 @@ func (pd *v2PushDescriptor) uploadUsingSession( return distribution.Descriptor{}, retryOnError(err) } - size, _ := pd.layer.Size() - - reader = progress.NewProgressReader(ioutils.NewCancelReadCloser(ctx, contentReader), progressOutput, size, pd.ID(), "Pushing") + reader = progress.NewProgressReader(ioutils.NewCancelReadCloser(ctx, contentReader), progressOutput, pd.layer.Size(), pd.ID(), "Pushing") switch m := pd.layer.MediaType(); m { case schema2.MediaTypeUncompressedLayer: @@ -596,7 +594,7 @@ attempts: // decision is based on layer size. The smaller the layer, the fewer attempts shall be made because the cost // of upload does not outweigh a latency. func getMaxMountAndExistenceCheckAttempts(layer PushLayer) (maxMountAttempts, maxExistenceCheckAttempts int, checkOtherRepositories bool) { - size, err := layer.Size() + size := layer.Size() switch { // big blob case size > middleLayerMaximumSize: @@ -606,7 +604,7 @@ func getMaxMountAndExistenceCheckAttempts(layer PushLayer) (maxMountAttempts, ma return 4, 3, true // middle sized blobs; if we could not get the size, assume we deal with middle sized blob - case size > smallLayerMaximumSize, err != nil: + case size > smallLayerMaximumSize: // 1st attempt to mount blobs of average size few times // 2nd try at most 1 existence check if there's an existing mapping to the target repository // then fallback to upload