mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume: avoid writing too much data for range requests in large files
related to https://github.com/chrislusf/seaweedfs/issues/3178
This commit is contained in:
parent
cc5d771088
commit
36d2756978
|
@ -14,9 +14,10 @@ func (n *Needle) ReadNeedleDataInto(r backend.BackendStorageFile, volumeOffset i
|
||||||
crc := CRC(0)
|
crc := CRC(0)
|
||||||
for x := needleOffset; x < needleOffset+size; x += int64(len(buf)) {
|
for x := needleOffset; x < needleOffset+size; x += int64(len(buf)) {
|
||||||
count, err := n.ReadNeedleData(r, volumeOffset, buf, x)
|
count, err := n.ReadNeedleData(r, volumeOffset, buf, x)
|
||||||
if count > 0 {
|
toWrite := min(int64(count), needleOffset+size-x)
|
||||||
crc = crc.Update(buf[0:count])
|
if toWrite > 0 {
|
||||||
if _, err = writer.Write(buf[0:count]); err != nil {
|
crc = crc.Update(buf[0:toWrite])
|
||||||
|
if _, err = writer.Write(buf[0:toWrite]); err != nil {
|
||||||
return fmt.Errorf("ReadNeedleData write: %v", err)
|
return fmt.Errorf("ReadNeedleData write: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue