From 7a2b932929cf5da997fad6a7bab87d89933f45d2 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Thu, 9 Jun 2016 11:22:58 +0200 Subject: [PATCH] warn if trying to compress/encrypt multivolume with mode w:... --- deltatar/tarfile.py | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/deltatar/tarfile.py b/deltatar/tarfile.py index 5630761..50dd856 100644 --- a/deltatar/tarfile.py +++ b/deltatar/tarfile.py @@ -1941,6 +1941,13 @@ class TarFile(object): if comptype == 'gz' or comptype == 'bz2': kwargs['compresslevel'] = compresslevel + if 'max_volume_size' in kwargs: + if comptype != 'tar' and filemode in 'wa' \ + and kwargs['max_volume_size']: + import warnings + warnings.warn('Only the first volume will be compressed ' + 'for modes with "w:"!') + return func(name, filemode, fileobj, **kwargs) elif "|" in mode: @@ -2481,6 +2488,7 @@ class TarFile(object): enctype=self.fileobj.enctype, concat_stream=self.fileobj.concat_stream) else: + # here, we lose information about compression/encryption! fileobj = bltn_open(name, self._mode) else: if name is None and hasattr(fileobj, "name"): -- 1.7.1