fix race-condition bug in publish command

Signed-off-by: Paul Thiele <paul.thiele@kinexon.com>
This commit is contained in:
Paul Thiele
2025-10-16 08:55:54 +02:00
committed by Nicolas De loof
parent 88aae9c46e
commit 157617480a

View File

@@ -125,10 +125,13 @@ func Push(ctx context.Context, resolver remotes.Resolver, ref reference.Named, d
if err != nil {
return err
}
defer func() {
_ = push.Close()
}()
_, err = push.Write(descriptor.Data)
return err
if err != nil {
// Close the writer on error since Commit won't be called
_ = push.Close()
return err
}
// Commit will close the writer
return push.Commit(ctx, int64(len(descriptor.Data)), descriptor.Digest)
}