handle zlib correctly
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Mon, 3 Apr 2017 15:32:44 +0000 (17:32 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:08 +0000 (13:34 +0200)
Encryption was split from the “compression mode” and now depends
entirely on the crypto context. Also only finalize a tar stream
being “closed” if the underlying file is being closed.

deltatar/tarfile.py

index 1788865..730f378 100644 (file)
@@ -618,7 +618,7 @@ class _Stream:
 
         # if aes, we encrypt after compression
         if self.encryption is not None:
-            raise Exception ("XXX sorry, no can do")
+            pass
         elif set_last_block_offset:
             self.last_block_offset = self.fileobj.tell()
 
@@ -712,9 +712,9 @@ class _Stream:
         if self.mode == "w":
             self._finalize_write_gz ()
             self.__enc_write(self.buf)
-            fixed = self._finalize_write_encrypt ()
 
         if close_fileobj is True:
+            fixed = self._finalize_write_encrypt ()
             if not self._extfileobj:
                 self.fileobj.close()
         else: