From 34cc456271f5a9850de7f908c9c0c78cb2b56f35 Mon Sep 17 00:00:00 2001 From: aron Date: Tue, 20 Dec 2016 16:03:19 +0100 Subject: [PATCH] swarm/storage: call size before seek-from-end --- swarm/storage/chunker.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/swarm/storage/chunker.go b/swarm/storage/chunker.go index c0f950de5c..d55875369d 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 }