##// END OF EJS Templates
bundle2: avoid unbound read when seeking...
Gregory Szorc -
r35117:699b2a75 default
parent child Browse files
Show More
@@ -1415,13 +1415,20 class seekableunbundlepart(unbundlepart)
1415 1415 newpos = self._pos + offset
1416 1416 elif whence == os.SEEK_END:
1417 1417 if not self.consumed:
1418 self.read()
1418 # Can't use self.consume() here because it advances self._pos.
1419 chunk = self.read(32768)
1420 while chunk:
1421 chunk = self.read(32768)
1419 1422 newpos = self._chunkindex[-1][0] - offset
1420 1423 else:
1421 1424 raise ValueError('Unknown whence value: %r' % (whence,))
1422 1425
1423 1426 if newpos > self._chunkindex[-1][0] and not self.consumed:
1424 self.read()
1427 # Can't use self.consume() here because it advances self._pos.
1428 chunk = self.read(32768)
1429 while chunk:
1430 chunk = self.read(32668)
1431
1425 1432 if not 0 <= newpos <= self._chunkindex[-1][0]:
1426 1433 raise ValueError('Offset out of range')
1427 1434
General Comments 0
You need to be logged in to leave comments. Login now