fix reading

This commit is contained in:
Chris Lu
2020-08-17 21:17:32 -07:00
parent 09e126bae5
commit 56fbd2c211
2 changed files with 126 additions and 1 deletions

View File

@@ -101,7 +101,7 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) {
return
}
bufferOffset := chunkStart - chunk.LogicOffset + chunk.Offset
copied := copy(p[chunkStart-startOffset:chunkStop-startOffset], buffer[bufferOffset:bufferOffset+chunkStop-chunkStart])
copied := copy(p[startOffset-offset:chunkStop-chunkStart+startOffset-offset], buffer[bufferOffset:bufferOffset+chunkStop-chunkStart])
n += copied
startOffset, remaining = startOffset+int64(copied), remaining-int64(copied)
}
@@ -111,6 +111,9 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) {
if remaining > 0 {
glog.V(4).Infof("zero2 [%d,%d)", n, n+int(remaining))
n += int(remaining)
if n > int(c.fileSize - offset){
n = int(c.fileSize - offset)
}
}
if offset+int64(n) >= c.fileSize {