upload: ignore the haveCache(s) when uploading a file blob with -vivify

Change-Id: Ic365c803322f01bcf1045456d4cebe74e870a7d2
This commit is contained in:
mpl 2013-01-30 16:06:03 +01:00
parent 0c2aa8058a
commit 464a138a7d
1 changed files with 16 additions and 12 deletions

View File

@ -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 {