apply compression if compressor is present
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Mon, 27 Mar 2017 09:11:00 +0000 (11:11 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:08 +0000 (13:34 +0200)
deltatar/tarfile.py

index d9c077a..9708f97 100644 (file)
@@ -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(<PASSWORD>, ā€œ%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: