Detection of handler depends on the wrong handler failing to list the contents of the tarfile. (#3584)
Use explicit compression types with the python tarfile library to achieve that.
This commit is contained in:
parent
d997c79487
commit
cd26cc8a0d
1 changed files with 7 additions and 1 deletions
|
@ -493,6 +493,7 @@ class TgzArchive(object):
|
||||||
# Fallback to tar
|
# Fallback to tar
|
||||||
self.cmd_path = self.module.get_bin_path('tar')
|
self.cmd_path = self.module.get_bin_path('tar')
|
||||||
self.zipflag = 'z'
|
self.zipflag = 'z'
|
||||||
|
self.compress_mode = 'gz'
|
||||||
self._files_in_archive = []
|
self._files_in_archive = []
|
||||||
|
|
||||||
def _get_tar_fileobj(self):
|
def _get_tar_fileobj(self):
|
||||||
|
@ -507,7 +508,7 @@ class TgzArchive(object):
|
||||||
# The use of Python's tarfile module here allows us to easily avoid tricky file encoding
|
# The use of Python's tarfile module here allows us to easily avoid tricky file encoding
|
||||||
# problems. Ref #11348
|
# problems. Ref #11348
|
||||||
try:
|
try:
|
||||||
tf = tarfile.open(fileobj=self._get_tar_fileobj())
|
tf = tarfile.open(fileobj=self._get_tar_fileobj(), mode='r:%s' % self.compress_mode)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise UnarchiveError('Unable to list files in the archive')
|
raise UnarchiveError('Unable to list files in the archive')
|
||||||
|
|
||||||
|
@ -593,7 +594,10 @@ class TgzArchive(object):
|
||||||
class TarArchive(TgzArchive):
|
class TarArchive(TgzArchive):
|
||||||
def __init__(self, src, dest, file_args, module):
|
def __init__(self, src, dest, file_args, module):
|
||||||
super(TarArchive, self).__init__(src, dest, file_args, module)
|
super(TarArchive, self).__init__(src, dest, file_args, module)
|
||||||
|
# argument to tar
|
||||||
self.zipflag = ''
|
self.zipflag = ''
|
||||||
|
# parameter for python tarfile library
|
||||||
|
self.compress_mode = ''
|
||||||
|
|
||||||
|
|
||||||
# class to handle bzip2 compressed tar files
|
# class to handle bzip2 compressed tar files
|
||||||
|
@ -601,6 +605,7 @@ class TarBzipArchive(TgzArchive):
|
||||||
def __init__(self, src, dest, file_args, module):
|
def __init__(self, src, dest, file_args, module):
|
||||||
super(TarBzipArchive, self).__init__(src, dest, file_args, module)
|
super(TarBzipArchive, self).__init__(src, dest, file_args, module)
|
||||||
self.zipflag = 'j'
|
self.zipflag = 'j'
|
||||||
|
self.compress_mode = 'bz2'
|
||||||
|
|
||||||
|
|
||||||
# class to handle xz compressed tar files
|
# class to handle xz compressed tar files
|
||||||
|
@ -608,6 +613,7 @@ class TarXzArchive(TgzArchive):
|
||||||
def __init__(self, src, dest, file_args, module):
|
def __init__(self, src, dest, file_args, module):
|
||||||
super(TarXzArchive, self).__init__(src, dest, file_args, module)
|
super(TarXzArchive, self).__init__(src, dest, file_args, module)
|
||||||
self.zipflag = 'J'
|
self.zipflag = 'J'
|
||||||
|
self.compress_mode = ''
|
||||||
|
|
||||||
def _get_tar_fileobj(self):
|
def _get_tar_fileobj(self):
|
||||||
# Python's tarfile module doesn't support xz compression so we have to manually uncompress
|
# Python's tarfile module doesn't support xz compression so we have to manually uncompress
|
||||||
|
|
Loading…
Reference in a new issue