mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Comparing with tar file checksums rather than tar header checksums
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user