xl: Fix GET of an empty multiparted object (#3646)

GetObject returns unsatisfied range error when we try to download an object
uploaded using multipart mechanism.
This commit is contained in:
Anis Elleuch 2017-01-27 19:51:02 +01:00 committed by Harshavardhana
parent 02194ee3c6
commit e1bc99e4fe
1 changed files with 7 additions and 1 deletions

View File

@ -198,8 +198,14 @@ func (xl xlObjects) GetObject(bucket, object string, startOffset int64, length i
return traceError(InvalidRange{startOffset, length, xlMeta.Stat.Size})
}
// Calculate endOffset according to length
endOffset := startOffset
if length > 0 {
endOffset += length - 1
}
// Get last part index to read given length.
lastPartIndex, _, err := xlMeta.ObjectToPartOffset(startOffset + length - 1)
lastPartIndex, _, err := xlMeta.ObjectToPartOffset(endOffset)
if err != nil {
return traceError(InvalidRange{startOffset, length, xlMeta.Stat.Size})
}