aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/stream.go
diff options
context:
space:
mode:
authorhilimd <68371223+hilimd@users.noreply.github.com>2020-10-14 16:39:45 +0800
committerGitHub <noreply@github.com>2020-10-14 16:39:45 +0800
commita91137579857a3ef40725dccda85f40d0ac77223 (patch)
treeab389cfefe7796600aeaca14773992daf7746752 /weed/filer/stream.go
parent2ff727a32d6d879a49ff5848b592518c96bb6403 (diff)
parent1069b325dd92b6a1b16a20290acc8129d5e19ef8 (diff)
downloadseaweedfs-a91137579857a3ef40725dccda85f40d0ac77223.tar.xz
seaweedfs-a91137579857a3ef40725dccda85f40d0ac77223.zip
Merge pull request #26 from chrislusf/master
sync
Diffstat (limited to 'weed/filer/stream.go')
-rw-r--r--weed/filer/stream.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/weed/filer/stream.go b/weed/filer/stream.go
index a41aebe22..363b07f14 100644
--- a/weed/filer/stream.go
+++ b/weed/filer/stream.go
@@ -2,6 +2,7 @@ package filer
import (
"bytes"
+ "fmt"
"io"
"math"
"strings"
@@ -35,10 +36,14 @@ func StreamContent(masterClient *wdclient.MasterClient, w io.Writer, chunks []*f
data, err := retriedFetchChunkData(urlStrings, chunkView.CipherKey, chunkView.IsGzipped, chunkView.IsFullChunk(), chunkView.Offset, int(chunkView.Size))
if err != nil {
- return err
+ glog.Errorf("read chunk: %v", err)
+ return fmt.Errorf("read chunk: %v", err)
+ }
+ _, err = w.Write(data)
+ if err != nil {
+ glog.Errorf("write chunk: %v", err)
+ return fmt.Errorf("write chunk: %v", err)
}
- w.Write(data)
-
}
return nil
@@ -174,10 +179,14 @@ func (c *ChunkStreamReader) fetchChunkToBuffer(chunkView *ChunkView) error {
return err
}
var buffer bytes.Buffer
+ var shouldRetry bool
for _, urlString := range urlStrings {
- err = util.ReadUrlAsStream(urlString, chunkView.CipherKey, chunkView.IsGzipped, chunkView.IsFullChunk(), chunkView.Offset, int(chunkView.Size), func(data []byte) {
+ shouldRetry, err = util.ReadUrlAsStream(urlString, chunkView.CipherKey, chunkView.IsGzipped, chunkView.IsFullChunk(), chunkView.Offset, int(chunkView.Size), func(data []byte) {
buffer.Write(data)
})
+ if !shouldRetry {
+ break
+ }
if err != nil {
glog.V(1).Infof("read %s failed, err: %v", chunkView.FileId, err)
buffer.Reset()