else:
self.addfile(tarinfo)
- def _size_left(self):
+ def _size_left_file(self):
"""Calculates size left in a volume with a maximum volume size.
Assumes self.max_volume_size is set.
"""
# limit size left to a discrete number of blocks, because we won't
# write only half a block when writting the end of a volume
# and filling with zeros
- blocks, remainder = divmod(size_left, BLOCKSIZE)
- return blocks*BLOCKSIZE
+ return BLOCKSIZE * (size_left // BLOCKSIZE)
+
+ def _size_left_stream(self):
+ size_left = self.max_volume_size - self.fileobj.estim_file_size() \
+ - 2*BLOCKSIZE
+ return BLOCKSIZE * (size_left // BLOCKSIZE)
def addfile(self, tarinfo, fileobj=None):
"""Add the TarInfo object `tarinfo' to the archive. If `fileobj' is