aboutsummaryrefslogtreecommitdiff
path: root/weed
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-04-29 02:42:58 -0700
committerChris Lu <chris.lu@gmail.com>2020-04-29 02:42:58 -0700
commit7c10602b49dca54591337597f48da6e228a7068d (patch)
treeec05a6ed68203c162984762bc9b8ebfa95c09137 /weed
parentf9da859720286d90c629a6cd6a002472a224a911 (diff)
downloadseaweedfs-7c10602b49dca54591337597f48da6e228a7068d.tar.xz
seaweedfs-7c10602b49dca54591337597f48da6e228a7068d.zip
read in case cross chunks
Diffstat (limited to 'weed')
-rw-r--r--weed/filer2/stream.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/weed/filer2/stream.go b/weed/filer2/stream.go
index bf1b4c24a..4e785fade 100644
--- a/weed/filer2/stream.go
+++ b/weed/filer2/stream.go
@@ -98,18 +98,20 @@ func NewChunkStreamReaderFromFiler(masterClient *wdclient.MasterClient, chunks [
}
}
-
func (c *ChunkStreamReader) Read(p []byte) (n int, err error) {
- if c.isBufferEmpty() {
- if c.chunkIndex >= len(c.chunkViews) {
- return 0, io.EOF
+ for n < len(p) {
+ if c.isBufferEmpty() {
+ 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]
- c.fetchChunkToBuffer(chunkView)
- c.chunkIndex++
+ t := copy(p[n:], c.buffer[c.bufferPos:])
+ c.bufferPos += t
+ n += t
}
- n = copy(p, c.buffer[c.bufferPos:])
- c.bufferPos += n
return
}