need to be more carful in determining whether is multi-volume or not
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 26 Jul 2016 07:58:30 +0000 (09:58 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 12 Nov 2020 14:04:34 +0000 (15:04 +0100)
deltatar/tarfile.py

index b6192f0..b973881 100644 (file)
@@ -2206,12 +2206,19 @@ class TarFile(object):
             if comptype == 'gz' or comptype == 'bz2':
                 kwargs['compresslevel'] = compresslevel
 
-            if 'max_volume_size' in kwargs or 'new_volume_handler' in kwargs:
-                if comptype != 'tar' and (kwargs['new_volume_handler'] or
-                                          kwargs['max_volume_size']):
-                    import warnings
-                    warnings.warn('Only the first volume will be compressed '
-                                  'for modes with "w:"!')
+            is_multivol = False
+            if filemode in 'wa' and 'max_volume_size' in kwargs \
+                    and kwargs['max_volume_size'] \
+                    and 'new_volume_handler' in kwargs \
+                    and kwargs['new_volume_handler']:
+                is_multivol = True
+            if filemode == 'r' and 'new_volume_handler' in kwargs \
+                    and kwargs['new_volume_handler']:
+                is_multivol = True     # may be multi-volume
+            if is_multivol and comptype != 'tar':
+                import warnings
+                warnings.warn('Only the first volume will be compressed '
+                              'for modes with "w:"!')
 
             return func(name, filemode, fileobj, **kwargs)