From 464a138a7d338be90772cf16d066dc17f0a4b280 Mon Sep 17 00:00:00 2001 From: mpl Date: Wed, 30 Jan 2013 16:06:03 +0100 Subject: [PATCH] upload: ignore the haveCache(s) when uploading a file blob with -vivify Change-Id: Ic365c803322f01bcf1045456d4cebe74e870a7d2 --- pkg/client/upload.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/pkg/client/upload.go b/pkg/client/upload.go index 35799b9d3..f0ee7354c 100644 --- a/pkg/client/upload.go +++ b/pkg/client/upload.go @@ -269,9 +269,11 @@ func (c *Client) Upload(h *UploadHandle) (*PutResult, error) { c.statsMutex.Unlock() pr := &PutResult{BlobRef: h.BlobRef, Size: bodySize} - if _, ok := c.haveCache.StatBlobCache(h.BlobRef); ok { - pr.Skipped = true - return pr, nil + if !h.Vivify { + if _, ok := c.haveCache.StatBlobCache(h.BlobRef); ok { + pr.Skipped = true + return pr, nil + } } blobrefStr := h.BlobRef.String() @@ -304,16 +306,18 @@ func (c *Client) Upload(h *UploadHandle) (*PutResult, error) { for _, sbr := range stat.HaveMap { c.haveCache.NoteBlobExists(sbr.BlobRef, sbr.Size) } - if _, ok := stat.HaveMap[blobrefStr]; ok { - pr.Skipped = true - if closer, ok := h.Contents.(io.Closer); ok { - // TODO(bradfitz): I did this - // Close-if-possible thing early on, before I - // knew better. Fix the callers instead, and - // fix the docs. - closer.Close() + if !h.Vivify { + if _, ok := stat.HaveMap[blobrefStr]; ok { + pr.Skipped = true + if closer, ok := h.Contents.(io.Closer); ok { + // TODO(bradfitz): I did this + // Close-if-possible thing early on, before I + // knew better. Fix the callers instead, and + // fix the docs. + closer.Close() + } + return pr, nil } - return pr, nil } if debugUploads {