mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Comparing with tar file checksums rather than tar header checksums
This commit is contained in:
parent
26fdd30542
commit
bed4b17107
1 changed files with 16 additions and 2 deletions
|
@ -247,6 +247,20 @@ def strip_prefix(prefix, string):
|
|||
return string[len(prefix):] if string.startswith(prefix) else string
|
||||
|
||||
|
||||
def tar_checksums(tar):
|
||||
result = []
|
||||
while True:
|
||||
info = tar.next()
|
||||
if info is None:
|
||||
break
|
||||
|
||||
f = tar.extractfile(info)
|
||||
|
||||
result += (info.name, crc32(f.read()) if f is not None else 0)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def _to_bytes(s):
|
||||
return to_bytes(s, errors='surrogate_or_strict')
|
||||
|
||||
|
@ -585,11 +599,11 @@ class TarArchive(Archive):
|
|||
if self.format == 'xz':
|
||||
with lzma.open(_to_native_ascii(path), 'r') as f:
|
||||
archive = tarfile.open(fileobj=f)
|
||||
checksums = set((info.name, info.chksum) for info in archive.getmembers())
|
||||
checksums = set(tar_checksums(archive))
|
||||
archive.close()
|
||||
else:
|
||||
archive = tarfile.open(_to_native_ascii(path), 'r|' + self.format)
|
||||
checksums = set((info.name, info.chksum) for info in archive.getmembers())
|
||||
checksums = set(tar_checksums(archive))
|
||||
archive.close()
|
||||
except (lzma.LZMAError, tarfile.ReadError, tarfile.CompressionError):
|
||||
try:
|
||||
|
|
Loading…
Reference in a new issue