aboutsummaryrefslogtreecommitdiffstats
path: root/swarm
diff options
context:
space:
mode:
authorAron Fischer <github@aron.guru>2016-12-22 07:34:05 +0800
committerFelix Lange <fjl@users.noreply.github.com>2016-12-22 07:34:05 +0800
commit301c0a6303d62ebe9b022736d816abe20924f63f (patch)
treee25458c092884ab1434f146c9f1b0208b880dd6b /swarm
parent65f486ff020a14e88f6d389935cacebfefe7d003 (diff)
downloaddexon-301c0a6303d62ebe9b022736d816abe20924f63f.tar.gz
dexon-301c0a6303d62ebe9b022736d816abe20924f63f.tar.zst
dexon-301c0a6303d62ebe9b022736d816abe20924f63f.zip
swarm/storage: call size before seek-from-end (#3469)
Diffstat (limited to 'swarm')
-rw-r--r--swarm/storage/chunker.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/swarm/storage/chunker.go b/swarm/storage/chunker.go
index c0f950de5..d55875369 100644
--- a/swarm/storage/chunker.go
+++ b/swarm/storage/chunker.go
@@ -483,8 +483,11 @@ func (s *LazyChunkReader) Seek(offset int64, whence int) (int64, error) {
case 1:
offset += s.off
case 2:
- if s.chunk == nil {
- return 0, fmt.Errorf("seek from the end requires rootchunk for size. call Size first")
+ if s.chunk == nil { //seek from the end requires rootchunk for size. call Size first
+ _, err := s.Size(nil)
+ if err != nil {
+ return 0, fmt.Errorf("can't get size: %v", err)
+ }
}
offset += s.chunk.Size
}