imagetools: fix oci-layout index update when blob exists

When pushing to an OCI layout where the top-level descriptor
blob already existed, pushOCILayout returned early without
updating index.json or writing pending referrers. Restructure
the control flow so the blob-exists case skips only the write
but still updates the index and flushes referrers.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2026-03-12 22:54:35 -07:00
parent 3e5c05cb1f
commit 6eb48d9c8c
2 changed files with 92 additions and 7 deletions
+7 -7
View File
@@ -558,14 +558,14 @@ func (r *Resolver) pushOCILayout(ctx context.Context, ref *Location, desc ocispe
}
w, err := store.Writer(ctx, content.WithRef(desc.Digest.String()), content.WithDescriptor(desc))
if err != nil {
if errdefs.IsAlreadyExists(err) {
return nil
if !errdefs.IsAlreadyExists(err) {
return err
}
} else {
err = content.Copy(ctx, w, bytes.NewReader(dt), desc.Size, desc.Digest)
if err != nil && !errdefs.IsAlreadyExists(err) {
return err
}
return err
}
err = content.Copy(ctx, w, bytes.NewReader(dt), desc.Size, desc.Digest)
if err != nil && !errdefs.IsAlreadyExists(err) {
return err
}
idx := ociindex.NewStoreIndex(ref.OCILayout().Path)