fix: Avoid teeing data into a null cache buffer (#5070)

In some cases, Cache manager returns ErrCacheFull error when creating a
new cache buffer but the code still sends object data to nil cache buffer data.
master
A. Elleuch 7 years ago committed by Dee Koder
parent 8287ab091c
commit b919462610
  1. 11
      cmd/xl-v1-object.go

@ -476,12 +476,15 @@ func (xl xlObjects) PutObject(bucket string, object string, data *HashReader, me
// Create a new entry in memory of size. // Create a new entry in memory of size.
newBuffer, err = xl.objCache.Create(path.Join(bucket, object), data.Size()) newBuffer, err = xl.objCache.Create(path.Join(bucket, object), data.Size())
// Ignore error if cache is full, proceed to write the object. if err == nil {
if err != nil && err != objcache.ErrCacheFull { // Cache incoming data into a buffer
// For any other error return here. reader = io.TeeReader(data, newBuffer)
} else {
// Return errors other than ErrCacheFull
if err != objcache.ErrCacheFull {
return ObjectInfo{}, toObjectErr(traceError(err), bucket, object) return ObjectInfo{}, toObjectErr(traceError(err), bucket, object)
} }
reader = io.TeeReader(data, newBuffer) }
} }
// Initialize parts metadata // Initialize parts metadata

Loading…
Cancel
Save