diff --git a/weed/filer/filechunk_manifest.go b/weed/filer/filechunk_manifest.go index dbc851496..8853db60a 100644 --- a/weed/filer/filechunk_manifest.go +++ b/weed/filer/filechunk_manifest.go @@ -135,23 +135,30 @@ func retriedFetchChunkData(urlStrings []string, cipherKey []byte, isGzipped bool func retriedStreamFetchChunkData(writer io.Writer, urlStrings []string, cipherKey []byte, isGzipped bool, isFullChunk bool, offset int64, size int) (err error) { var shouldRetry bool - var written int + var totalWritten int for waitTime := time.Second; waitTime < util.RetryWaitTime; waitTime += waitTime / 2 { for _, urlString := range urlStrings { + var localProcesed int shouldRetry, err = util.ReadUrlAsStream(urlString+"?readDeleted=true", cipherKey, isGzipped, isFullChunk, offset, size, func(data []byte) { + if totalWritten > localProcesed { + toBeSkipped := totalWritten - localProcesed + if len(data) <= toBeSkipped { + localProcesed += len(data) + return // skip if already processed + } + data = data[len(data)-toBeSkipped:] + localProcesed += toBeSkipped + } writer.Write(data) - written += len(data) + localProcesed += len(data) + totalWritten += len(data) }) - shouldRetry = shouldRetry && written == 0 if !shouldRetry { break } if err != nil { glog.V(0).Infof("read %s failed, err: %v", urlString, err) - if written > 0 { - break - } } else { break }