refactoring

This commit is contained in:
Chris Lu
2020-10-08 23:19:42 -07:00
parent b2ee5873fb
commit 6e1f936efd
2 changed files with 18 additions and 23 deletions

View File

@@ -89,10 +89,15 @@ func fetchChunk(lookupFileIdFn LookupFileIdFunctionType, fileId string, cipherKe
glog.Errorf("operation LookupFileId %s failed, err: %v", fileId, err)
return nil, err
}
var buffer bytes.Buffer
return fetchChunkData(urlStrings, cipherKey, isGzipped, true, 0, 0)
}
func fetchChunkData(urlStrings []string, cipherKey []byte, isGzipped bool, isFullChunk bool, offset int64, size int) ([]byte, error) {
var err error
var buffer bytes.Buffer
for _, urlString := range urlStrings {
err = util.ReadUrlAsStream(urlString, cipherKey, isGzipped, true, 0, 0, func(data []byte) {
err = util.ReadUrlAsStream(urlString, cipherKey, isGzipped, isFullChunk, offset, size, func(data []byte) {
buffer.Write(data)
})
if err != nil {