properly (re-) initialize compressor at archive / volume bounds
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Tue, 25 Apr 2017 12:03:36 +0000 (14:03 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:08 +0000 (13:34 +0200)
For unencrypted streams, the compressor still must be reset in
concat mode. For encrypted streams, the decompressor can be
initialized right at the start of the archive since no further
inputs are needed.

deltatar/tarfile.py

index e3659a3..78fdad8 100644 (file)
@@ -463,8 +463,7 @@ class _Stream:
                 self.zlib = zlib
                 if mode == "r":
                     self.exception = zlib.error
-                    if self.encryption is None:
-                        self._init_read_gz()
+                    self._init_read_gz()
                 elif mode == "w":
                     if self.encryption is None and concat_stream is False:
                         self._init_write_gz ()
@@ -2515,7 +2514,8 @@ class TarFile(object):
 
                 if getattr (self.fileobj, "encryption", None) is not None:
                     self.fileobj._init_write_encrypt (tarinfo.name)
-                if getattr (self.fileobj, "cmp", None) is not None:
+                if self.concat_compression or \
+                        getattr (self.fileobj, "cmp", None) is not None:
                     self.fileobj._init_write_gz ()
 
                 # write new volume header