Browse Source

volume: avoid writing too much data for range requests in large files

related to https://github.com/chrislusf/seaweedfs/issues/3178
pull/3185/head
chrislu 3 years ago
parent
commit
36d2756978
  1. 7
      weed/storage/needle/needle_read_page.go

7
weed/storage/needle/needle_read_page.go

@ -14,9 +14,10 @@ func (n *Needle) ReadNeedleDataInto(r backend.BackendStorageFile, volumeOffset i
crc := CRC(0)
for x := needleOffset; x < needleOffset+size; x += int64(len(buf)) {
count, err := n.ReadNeedleData(r, volumeOffset, buf, x)
if count > 0 {
crc = crc.Update(buf[0:count])
if _, err = writer.Write(buf[0:count]); err != nil {
toWrite := min(int64(count), needleOffset+size-x)
if toWrite > 0 {
crc = crc.Update(buf[0:toWrite])
if _, err = writer.Write(buf[0:toWrite]); err != nil {
return fmt.Errorf("ReadNeedleData write: %v", err)
}
}

Loading…
Cancel
Save