From 537329005c5eb92155dcb79081317a4c1d68348b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 27 Mar 2017 11:11:00 +0200 Subject: [PATCH] apply compression if compressor is present --- deltatar/tarfile.py | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index d9c077a..9708f97 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -29,7 +29,7 @@ """Read from and write to tar format archives. """ -I2N_XXX_ENCRYPTION_VERSION = 0 +I2N_XXX_ENCRYPTION_VERSION = 1 __version__ = "$Revision: 85213 $" # $Source$ @@ -400,6 +400,7 @@ class _Stream: self.name = name or "" self.mode = mode self.comptype = comptype + self.cmp = None self.fileobj = fileobj self.bufsize = bufsize self.buf = b"" @@ -459,7 +460,7 @@ class _Stream: ("ctor failed crypto.Encrypt(, “%s”, %r)" % (nacl, 1)) self.encryption = enc - self._init_write_gz() + #self._init_write_gz() self.exception = zlib.error # XXX what for? seems unused self.crc = zlib.crc32(b"") & 0xFFFFffff @@ -653,7 +654,7 @@ class _Stream: self.crc = self.zlib.crc32(s, self.crc) & 0xFFFFffff self.pos += len(s) self.concat_pos += len(s) - if self.comptype != "tar": + if self.cmp is not None: s = self.cmp.compress(s) self.__write(s) @@ -679,8 +680,6 @@ class _Stream: given, the streem will seek to that position first and back afterwards, and the total of bytes written is not updated. ''' - % (len (s), - ("" if pos is None else (" at 0x%x" % pos)))) if pos is not None: self.fileobj p0 = self.fileobj.tell () @@ -734,7 +733,7 @@ class _Stream: if self.closed: return - if self.mode == "w" and self.comptype != "tar": + if self.mode == "w" and self.cmp is not None: self.buf += self.cmp.flush() if self.mode == "w" and self.buf: @@ -916,7 +915,7 @@ class _Stream: if not buf: break - if self.comptype != "tar": + if self.cmp is not None: try: buf = self.cmp.decompress(buf) except IOError: -- 1.7.1