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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user