mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
swarm/storage: Handle case when read returns less than the size of target slice
This commit is contained in:
parent
840505dfd2
commit
4936bec6c9
1 changed files with 8 additions and 4 deletions
|
|
@ -178,11 +178,15 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data io.Reade
|
||||||
// leaf nodes -> content chunks
|
// leaf nodes -> content chunks
|
||||||
chunkData := make([]byte, size+8)
|
chunkData := make([]byte, size+8)
|
||||||
binary.LittleEndian.PutUint64(chunkData[0:8], uint64(size))
|
binary.LittleEndian.PutUint64(chunkData[0:8], uint64(size))
|
||||||
n, err := data.Read(chunkData[8:])
|
var readBytes int64
|
||||||
if err != nil && !(err == io.EOF && int64(n) == size) {
|
for readBytes < size {
|
||||||
|
n, err := data.Read(chunkData[8+readBytes:])
|
||||||
|
readBytes += int64(n)
|
||||||
|
if err != nil && !(err == io.EOF && readBytes == size) {
|
||||||
errC <- err
|
errC <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
select {
|
select {
|
||||||
case jobC <- &hashJob{key, chunkData, size, parentWg}:
|
case jobC <- &hashJob{key, chunkData, size, parentWg}:
|
||||||
case <-quitC:
|
case <-quitC:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue