From defc9a22f698b9a0844111bad5053603f4b2ca80 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Thu, 9 Jun 2016 17:56:00 +0200 Subject: [PATCH] created a 2nd TarFile._size_left: one for file and one for stream --- deltatar/tarfile.py | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-) 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 -- 1.7.1