mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
(cherry picked from commit 5aa1e58749
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
ec11d13825
commit
1b78f18bf4
3 changed files with 39 additions and 10 deletions
|
@ -581,6 +581,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:
|
||||
|
@ -591,7 +596,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