Scope writer locks to each writer.

Signed-off-by: Niklas Gehlen <niklas@namespacelabs.com>
This commit is contained in:
Niklas Gehlen
2024-10-23 20:39:51 +02:00
parent b291eb802b
commit 2535b187a6
4 changed files with 23 additions and 24 deletions

View File

@@ -78,7 +78,7 @@ func (w *writer) Write(p []byte) (n int, err error) {
func (w *writer) Commit(ctx context.Context, size int64, expected digest.Digest, opts ...content.Opt) error {
// Ensure even on error the writer is fully closed
defer unlock(w.ref)
defer w.s.unlock(w.ref)
var base content.Info
for _, opt := range opts {
@@ -198,7 +198,7 @@ func (w *writer) Close() (err error) {
err = w.fp.Close()
writeTimestampFile(filepath.Join(w.path, "updatedat"), w.updatedAt)
w.fp = nil
unlock(w.ref)
w.s.unlock(w.ref)
return
}