aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViktor TrĂ³n <viktor.tron@gmail.com>2016-10-14 03:43:57 +0800
committerGitHub <noreply@github.com>2016-10-14 03:43:57 +0800
commitf63c6c008f6341a8a46ae1f424b0e7b43ec25583 (patch)
tree976e7c83b074dd1ce693515db0fecd7437350bd2
parent30fb5c3e81f88fe27b48a058e25f04b70deeaada (diff)
parenteb2f01aee885994a28b3eb28d558f5b7a1c72b5f (diff)
downloaddexon-f63c6c008f6341a8a46ae1f424b0e7b43ec25583.tar
dexon-f63c6c008f6341a8a46ae1f424b0e7b43ec25583.tar.gz
dexon-f63c6c008f6341a8a46ae1f424b0e7b43ec25583.tar.bz2
dexon-f63c6c008f6341a8a46ae1f424b0e7b43ec25583.tar.lz
dexon-f63c6c008f6341a8a46ae1f424b0e7b43ec25583.tar.xz
dexon-f63c6c008f6341a8a46ae1f424b0e7b43ec25583.tar.zst
dexon-f63c6c008f6341a8a46ae1f424b0e7b43ec25583.zip
Merge pull request #3133 from ethersphere/http-fix
swarm: fix http API's last problems
-rw-r--r--swarm/storage/chunker.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/swarm/storage/chunker.go b/swarm/storage/chunker.go
index b22b4c813..c0f950de5 100644
--- a/swarm/storage/chunker.go
+++ b/swarm/storage/chunker.go
@@ -178,10 +178,14 @@ func (self *TreeChunker) split(depth int, treeSize int64, key Key, data io.Reade
// leaf nodes -> content chunks
chunkData := make([]byte, size+8)
binary.LittleEndian.PutUint64(chunkData[0:8], uint64(size))
- _, err := data.Read(chunkData[8:])
- if err != nil {
- errC <- err
- return
+ var readBytes int64
+ for readBytes < size {
+ n, err := data.Read(chunkData[8+readBytes:])
+ readBytes += int64(n)
+ if err != nil && !(err == io.EOF && readBytes == size) {
+ errC <- err
+ return
+ }
}
select {
case jobC <- &hashJob{key, chunkData, size, parentWg}:
@@ -371,7 +375,6 @@ func (self *LazyChunkReader) join(b []byte, off int64, eoff int64, depth int, tr
defer parentWg.Done()
// return NewDPA(&LocalStore{})
-
// chunk.Size = int64(binary.LittleEndian.Uint64(chunk.SData[0:8]))
// find appropriate block level