From: Philipp Gesang Date: Mon, 27 Mar 2017 14:06:18 +0000 (+0200) Subject: explicitly constuct zlib headers X-Git-Tag: v2.2~7^2~207 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=15a81fc089e18d800aaf8508a353ba7cba4eedca;p=python-delta-tar explicitly constuct zlib headers Get rid of the unnecessary literal byte strings. Commit 5fdff89f4d9fa28e6b210d40d389680072651eb7 introduced headers for additional blocks, omitting the “original file name” field that gzip set by default. --- diff --git a/deltatar/deltatar.py b/deltatar/deltatar.py index 5ff2893..f5493ce 100644 --- a/deltatar/deltatar.py +++ b/deltatar/deltatar.py @@ -18,7 +18,7 @@ # Author: Eduardo Robles Elvira -I2N_XXX_ENCRYPTION_VERSION = 0 +I2N_XXX_ENCRYPTION_VERSION = 1 import logging import datetime @@ -499,6 +499,7 @@ class DeltaTar(object): comptype = 'tar' encver = None + counter = None if 'aes' in self.index_mode: encver = I2N_XXX_ENCRYPTION_VERSION counter = None diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index e4b6910..3576879 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -120,6 +120,13 @@ DEFAULT_FORMAT = GNU_FORMAT DELTATAR_HEADER_VERSION = 1 DELTATAR_PARAMETER_VERSION = 1 +GZ_FMT_HEADER = b")") self.encryption = enc else: - if self.encver is None: + if self.encver is not None: # Layers are stacked differently: initialization is # necessary per file. if password is None: @@ -460,7 +493,6 @@ class _Stream: ("ctor failed crypto.Encrypt(, “%s”, %r)" % (nacl, 1)) self.encryption = enc - #self._init_write_gz() self.exception = zlib.error # XXX what for? seems unused self.crc = zlib.crc32(b"") & 0xFFFFffff @@ -588,28 +620,6 @@ class _Stream: self.lasthdr = -1 - def _init_write_gz(self): - """Initialize for writing with gzip compression. - """ - if getattr(self, "zlib", None) is None: - return - self.cmp = self.zlib.compressobj(self.compresslevel, - self.zlib.DEFLATED, - -self.zlib.MAX_WBITS, - self.zlib.DEF_MEM_LEVEL, - 0) - timestamp = struct.pack(" 0: