swarm/storage: call size before seek-from-end (#3469)

This commit is contained in:
Aron Fischer 2016-12-22 00:34:05 +01:00 committed by Felix Lange
parent 65f486ff02
commit 301c0a6303
1 changed files with 5 additions and 2 deletions

View File

@ -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
}