From a8fdd04e62a78d89cdaa687a4541281f49964229 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 8 May 2016 15:39:24 -0700 Subject: [PATCH] erasure: ReadFile should honor proper offsets. (#1542) Fixes #1535 --- xl-erasure-v1-readfile.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xl-erasure-v1-readfile.go b/xl-erasure-v1-readfile.go index 73c434b65..e29c1cdc2 100644 --- a/xl-erasure-v1-readfile.go +++ b/xl-erasure-v1-readfile.go @@ -174,13 +174,14 @@ func (xl XL) ReadFile(volume, path string, startOffset int64) (io.ReadCloser, er // Verify if the offset is right for the block, if not move to // the next block. + if startOffset > 0 { startOffset = startOffset - int64(len(dataBlocks)) - if startOffset > int64(len(dataBlocks)) { + // Start offset is greater than or equal to zero, skip the dataBlocks. + if startOffset >= 0 { continue } - // Fetch back the overflow offset, to skip from the current data - // blocks. + // Now get back the remaining offset if startOffset is negative. startOffset = startOffset + int64(len(dataBlocks)) }