mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
read in case cross chunks
This commit is contained in:
parent
f9da859720
commit
7c10602b49
|
@ -98,18 +98,20 @@ func NewChunkStreamReaderFromFiler(masterClient *wdclient.MasterClient, chunks [
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (c *ChunkStreamReader) Read(p []byte) (n int, err error) {
|
func (c *ChunkStreamReader) Read(p []byte) (n int, err error) {
|
||||||
if c.isBufferEmpty() {
|
for n < len(p) {
|
||||||
if c.chunkIndex >= len(c.chunkViews) {
|
if c.isBufferEmpty() {
|
||||||
return 0, io.EOF
|
if c.chunkIndex >= len(c.chunkViews) {
|
||||||
|
return n, io.EOF
|
||||||
|
}
|
||||||
|
chunkView := c.chunkViews[c.chunkIndex]
|
||||||
|
c.fetchChunkToBuffer(chunkView)
|
||||||
|
c.chunkIndex++
|
||||||
}
|
}
|
||||||
chunkView := c.chunkViews[c.chunkIndex]
|
t := copy(p[n:], c.buffer[c.bufferPos:])
|
||||||
c.fetchChunkToBuffer(chunkView)
|
c.bufferPos += t
|
||||||
c.chunkIndex++
|
n += t
|
||||||
}
|
}
|
||||||
n = copy(p, c.buffer[c.bufferPos:])
|
|
||||||
c.bufferPos += n
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue