From: Christian Herdtweck Date: Thu, 9 Jun 2016 15:56:00 +0000 (+0200) Subject: created a 2nd TarFile._size_left: one for file and one for stream X-Git-Tag: v2.2~35^2~23 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=defc9a22f698b9a0844111bad5053603f4b2ca80;p=python-delta-tar created a 2nd TarFile._size_left: one for file and one for stream --- diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index 50dd856..230b47e 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -2358,7 +2358,7 @@ class TarFile(object): 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. """ @@ -2366,8 +2366,12 @@ class TarFile(object): # 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