update comment: the "-2 * BLOCKSIZE" in size_left has 2 reasons, not just 1
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 15 Jul 2016 10:42:52 +0000 (12:42 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 12 Nov 2021 12:32:59 +0000 (13:32 +0100)
deltatar/tarfile.py

index 9be864a..1115373 100644 (file)
@@ -2637,7 +2637,8 @@ class TarFile(object):
         Assumes self.max_volume_size is set.
         If using compression through a _Stream, use _size_left_stream instead
         """
-        # left-over size = max_size - offset - 2 zero-blocks written in close
+        # left-over size = max_size - offset - 2 blocks (either 2 zero-blocks
+        #  written in close or 1 tarinfo-block + first data block of next file)
         size_left = self.max_volume_size - 2*BLOCKSIZE - self.offset
         # 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
@@ -2650,7 +2651,8 @@ class TarFile(object):
         Assumes self.max_volume_size is set and self.fileobj is a _Stream
         (otherwise use _size_left_file)
         """
-        # left-over size = max_size - bytes written - 2 zero-blocks (close)
+        # left-over size = max_size - offset - 2 blocks (either 2 zero-blocks
+        #  written in close or 1 tarinfo-block + first data block of next file)
         size_left = self.max_volume_size - self.fileobj.estim_file_size() \
             - 2*BLOCKSIZE
         return BLOCKSIZE * (size_left // BLOCKSIZE)