mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-11-24 19:19:11 +08:00
download 2 chunks if at the beginning of a file
This commit is contained in:
parent
f9d9eed0c9
commit
941ced60a4
@ -168,10 +168,16 @@ func (c *ChunkReadAt) readChunkSliceAt(buffer []byte, chunkView *ChunkView, next
|
|||||||
}
|
}
|
||||||
|
|
||||||
n, err = c.readerCache.ReadChunkAt(buffer, chunkView.FileId, chunkView.CipherKey, chunkView.IsGzipped, int64(offset), int(chunkView.ChunkSize), chunkView.LogicOffset == 0)
|
n, err = c.readerCache.ReadChunkAt(buffer, chunkView.FileId, chunkView.CipherKey, chunkView.IsGzipped, int64(offset), int(chunkView.ChunkSize), chunkView.LogicOffset == 0)
|
||||||
if c.lastChunkFid != "" && c.lastChunkFid != chunkView.FileId {
|
if c.lastChunkFid != chunkView.FileId {
|
||||||
if chunkView.Offset == 0 { // start of a new chunk
|
if chunkView.Offset == 0 { // start of a new chunk
|
||||||
|
if c.lastChunkFid != "" {
|
||||||
c.readerCache.UnCache(c.lastChunkFid)
|
c.readerCache.UnCache(c.lastChunkFid)
|
||||||
c.readerCache.MaybeCache(nextChunkViews)
|
c.readerCache.MaybeCache(nextChunkViews)
|
||||||
|
} else {
|
||||||
|
if len(nextChunkViews) >= 1 {
|
||||||
|
c.readerCache.MaybeCache(nextChunkViews[:1]) // just read the next chunk if at the very beginning
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.lastChunkFid = chunkView.FileId
|
c.lastChunkFid = chunkView.FileId
|
||||||
|
Loading…
Reference in New Issue
Block a user