From 38c3cc71ded6a5dee53536f6f418b28648d7c453 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Wed, 14 Jun 2017 14:54:13 -0700 Subject: [PATCH] Content store writer checks expected Fixes #1004 Signed-off-by: Derek McGowan --- content/store.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/content/store.go b/content/store.go index fd68e3c5e..2a45c1658 100644 --- a/content/store.go +++ b/content/store.go @@ -227,8 +227,14 @@ func (s *store) total(ingestPath string) int64 { // // The argument `ref` is used to uniquely identify a long-lived writer transaction. func (s *store) Writer(ctx context.Context, ref string, total int64, expected digest.Digest) (Writer, error) { - // TODO(stevvooe): Need to actually store and handle expected here. We have + // TODO(stevvooe): Need to actually store expected here. We have // code in the service that shouldn't be dealing with this. + if expected != "" { + p := s.blobPath(expected) + if _, err := os.Stat(p); err == nil { + return nil, ErrExists + } + } path, refp, data := s.ingestPaths(ref)