diff --git a/registry/push.go b/registry/push.go index 76a2ab1..e7453f4 100644 --- a/registry/push.go +++ b/registry/push.go @@ -14,7 +14,7 @@ import ( ) var ( - // if a manifest or blob is more than this many bytes, we'll do a pre-flight HEAD request to verify whether we need to even bother pushing it before we do so (65535 is the theoretical maximum size of a single TCP packet, although MTU means it's usually closer to 1448 bytes, but this seemed like a sane place to draw a line to where a second request that might fail is worth our time) + // if a blob is more than this many bytes, we'll do a pre-flight HEAD request to verify whether we need to even bother pushing it before we do so (65535 is the theoretical maximum size of a single TCP packet, although MTU means it's usually closer to 1448 bytes, but this seemed like a sane place to draw a line to where a second request that might fail is worth our time) BlobSizeWorthHEAD = int64(65535) ) @@ -43,18 +43,18 @@ func EnsureManifest(ctx context.Context, ref Reference, manifest json.RawMessage return desc, fmt.Errorf("%s: failed getting client: %w", ref, err) } - if desc.Size > BlobSizeWorthHEAD { - r, err := Lookup(ctx, ref, &LookupOptions{Head: true}) - if err != nil { - return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err) - } - // TODO if we had some kind of progress interface, this would be a great place for some kind of debug log of head's contents - if r != nil { - head := r.Descriptor() - r.Close() - if head.Digest == desc.Digest && head.Size == desc.Size { - return head, nil - } + // try HEAD request before pushing + // if it matches, then we can assume child objects exist as well + r, err := Lookup(ctx, ref, &LookupOptions{Head: true}) + if err != nil { + return desc, fmt.Errorf("%s: failed HEAD: %w", ref, err) + } + // TODO if we had some kind of progress interface, this would be a great place for some kind of debug log of head's contents + if r != nil { + head := r.Descriptor() + r.Close() + if head.Digest == desc.Digest && head.Size == desc.Size { + return head, nil } }