warn if trying to compress/encrypt multivolume with mode w:...
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 9 Jun 2016 09:22:58 +0000 (11:22 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Wed, 15 Jun 2016 11:18:02 +0000 (13:18 +0200)
deltatar/tarfile.py

index 5630761..50dd856 100644 (file)
@@ -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"):