Sfoglia il codice sorgente

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 <github@gone.nl>
Sebastiaan van Stijn 3 anni fa
parent
commit
f9a1846ca2
2 ha cambiato i file con 6 aggiunte e 8 eliminazioni
  1. 3 3
      distribution/config.go
  2. 3 5
      distribution/push_v2.go

+ 3 - 3
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 {

+ 3 - 5
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