Skip to content

Commit

Permalink
Merge pull request #34 from sudo-bmitch/pr-mem-blob-create-race
Browse files Browse the repository at this point in the history
Fix a race in mem.BlobCreate
  • Loading branch information
sudo-bmitch committed Dec 25, 2023
2 parents cf73c51 + e5fc93d commit 357bcc4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/store/mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ func (mr *memRepo) BlobCreate(opts ...BlobOpt) (BlobCreator, error) {
}
// if blob exists, return the appropriate error
if conf.expect != "" {
if _, ok := mr.blobs[conf.expect]; ok {
mr.mu.Lock()
_, ok := mr.blobs[conf.expect]
mr.mu.Unlock()
if ok {
return nil, types.ErrBlobExists
}
}
Expand Down

0 comments on commit 357bcc4

Please sign in to comment.