mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Do not crash when lzma is not around. (#5393)
This commit is contained in:
parent
c3bdc4b394
commit
5aa1e58749
3 changed files with 39 additions and 10 deletions
|
@ -575,6 +575,11 @@ class TarArchive(Archive):
|
|||
self.file.add(path, archive_name, recursive=False, exclude=py26_filter)
|
||||
|
||||
def _get_checksums(self, path):
|
||||
if HAS_LZMA:
|
||||
LZMAError = lzma.LZMAError
|
||||
else:
|
||||
# Just picking another exception that's also listed below
|
||||
LZMAError = tarfile.ReadError
|
||||
try:
|
||||
if self.format == 'xz':
|
||||
with lzma.open(_to_native_ascii(path), 'r') as f:
|
||||
|
@ -585,7 +590,7 @@ class TarArchive(Archive):
|
|||
archive = tarfile.open(_to_native_ascii(path), 'r|' + self.format)
|
||||
checksums = set((info.name, info.chksum) for info in archive.getmembers())
|
||||
archive.close()
|
||||
except (lzma.LZMAError, tarfile.ReadError, tarfile.CompressionError):
|
||||
except (LZMAError, tarfile.ReadError, tarfile.CompressionError):
|
||||
try:
|
||||
# The python implementations of gzip, bz2, and lzma do not support restoring compressed files
|
||||
# to their original names so only file checksum is returned
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue