mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
avoid empty chunk view
This commit is contained in:
parent
d773e11c7a
commit
e18c7e160c
|
@ -66,7 +66,7 @@ func ReadFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views
|
|||
stop := offset + int64(size)
|
||||
|
||||
for _, chunk := range visibles {
|
||||
if chunk.start <= offset && offset < chunk.stop {
|
||||
if chunk.start <= offset && offset < chunk.stop && offset < stop {
|
||||
views = append(views, &ChunkView{
|
||||
FileId: chunk.fileId,
|
||||
Offset: offset - chunk.start, // offset is the data starting location in this file id
|
||||
|
|
|
@ -249,6 +249,20 @@ func TestChunksReading(t *testing.T) {
|
|||
{Offset: 0, Size: 100, FileId: "abc", LogicOffset:0},
|
||||
},
|
||||
},
|
||||
// case 7: edge cases
|
||||
{
|
||||
Chunks: []*filer_pb.FileChunk{
|
||||
{Offset: 0, Size: 100, FileId: "abc", Mtime: 123},
|
||||
{Offset: 100, Size: 100, FileId: "asdf", Mtime: 134},
|
||||
{Offset: 200, Size: 100, FileId: "fsad", Mtime: 353},
|
||||
},
|
||||
Offset: 0,
|
||||
Size: 200,
|
||||
Expected: []*ChunkView{
|
||||
{Offset: 0, Size: 100, FileId: "abc", LogicOffset:0},
|
||||
{Offset: 0, Size: 100, FileId: "asdf", LogicOffset:100},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, testcase := range testcases {
|
||||
|
|
Loading…
Reference in a new issue