1
0
mirror of https://github.com/minio/mc.git synced 2025-11-12 01:02:26 +03:00

Fix downloading files with exact ranges requested in client FS. (#1892)

This is due to the fact that ReadAt() will not send io.EOF
when reading past the offset, server instead returns
Range error. Handle the error by only reading until the
requested size.
This commit is contained in:
Harshavardhana
2016-11-21 02:53:24 -08:00
committed by GitHub
parent e1ed7c65e7
commit b51e6b0485

View File

@@ -246,12 +246,13 @@ func (f *fsClient) Put(reader io.Reader, size int64, contentType string, progres
return 0, probe.NewError(e)
}
}
// Allocate buffer of 10MiB once.
readAtBuffer := make([]byte, 10*1024*1024)
// Loop through all offsets on incoming io.ReaderAt and write
// to the destination.
for {
for currentOffset < size {
readAtSize, re := readerAt.ReadAt(readAtBuffer, currentOffset)
if re != nil && re != io.EOF {
// For any errors other than io.EOF, we return error