refactor
This commit is contained in:
@@ -73,7 +73,7 @@ type ChunkView struct {
|
|||||||
LogicOffset int64
|
LogicOffset int64
|
||||||
IsFullChunk bool
|
IsFullChunk bool
|
||||||
CipherKey []byte
|
CipherKey []byte
|
||||||
isGzipped bool
|
IsGzipped bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int64) (views []*ChunkView) {
|
func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int64) (views []*ChunkView) {
|
||||||
@@ -105,7 +105,7 @@ func ViewFromVisibleIntervals(visibles []VisibleInterval, offset int64, size int
|
|||||||
LogicOffset: offset,
|
LogicOffset: offset,
|
||||||
IsFullChunk: isFullChunk,
|
IsFullChunk: isFullChunk,
|
||||||
CipherKey: chunk.cipherKey,
|
CipherKey: chunk.cipherKey,
|
||||||
isGzipped: chunk.isGzipped,
|
IsGzipped: chunk.isGzipped,
|
||||||
})
|
})
|
||||||
offset = min(chunk.stop, stop)
|
offset = min(chunk.stop, stop)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ func StreamContent(masterClient *wdclient.MasterClient, w io.Writer, chunks []*f
|
|||||||
for _, chunkView := range chunkViews {
|
for _, chunkView := range chunkViews {
|
||||||
|
|
||||||
urlString := fileId2Url[chunkView.FileId]
|
urlString := fileId2Url[chunkView.FileId]
|
||||||
err := util.ReadUrlAsStream(urlString, chunkView.CipherKey, chunkView.isGzipped, chunkView.IsFullChunk, chunkView.Offset, int(chunkView.Size), func(data []byte) {
|
err := util.ReadUrlAsStream(urlString, chunkView.CipherKey, chunkView.IsGzipped, chunkView.IsFullChunk, chunkView.Offset, int(chunkView.Size), func(data []byte) {
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -128,7 +128,7 @@ func (c *ChunkStreamReader) fetchChunkToBuffer(chunkView *ChunkView) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
err = util.ReadUrlAsStream(urlString, chunkView.CipherKey, chunkView.isGzipped, chunkView.IsFullChunk, chunkView.Offset, int(chunkView.Size), func(data []byte) {
|
err = util.ReadUrlAsStream(urlString, chunkView.CipherKey, chunkView.IsGzipped, chunkView.IsFullChunk, chunkView.Offset, int(chunkView.Size), func(data []byte) {
|
||||||
buffer.Write(data)
|
buffer.Write(data)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user