|
|
|
@ -55,7 +55,7 @@ from collections.abc import (
|
|
|
|
Set,
|
|
|
|
Set,
|
|
|
|
MutableSet,
|
|
|
|
MutableSet,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from functools import reduce
|
|
|
|
from functools import reduce, partial
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
import syslog
|
|
|
|
import syslog
|
|
|
|
@ -1620,13 +1620,11 @@ class AnsibleModule(object):
|
|
|
|
self.fail_json(msg="Could not hash file '%s' with algorithm '%s'. Available algorithms: %s" %
|
|
|
|
self.fail_json(msg="Could not hash file '%s' with algorithm '%s'. Available algorithms: %s" %
|
|
|
|
(filename, algorithm, ', '.join(AVAILABLE_HASH_ALGORITHMS)))
|
|
|
|
(filename, algorithm, ', '.join(AVAILABLE_HASH_ALGORITHMS)))
|
|
|
|
|
|
|
|
|
|
|
|
blocksize = 64 * 1024
|
|
|
|
blocksize = (64 * 1024) // digest_method.block_size * digest_method.block_size
|
|
|
|
infile = open(os.path.realpath(b_filename), 'rb')
|
|
|
|
digest_update = digest_method.update
|
|
|
|
block = infile.read(blocksize)
|
|
|
|
with open(os.path.realpath(b_filename), 'rb') as f:
|
|
|
|
while block:
|
|
|
|
for b_block in iter(partial(f.read, blocksize), b''):
|
|
|
|
digest_method.update(block)
|
|
|
|
digest_update(b_block)
|
|
|
|
block = infile.read(blocksize)
|
|
|
|
|
|
|
|
infile.close()
|
|
|
|
|
|
|
|
return digest_method.hexdigest()
|
|
|
|
return digest_method.hexdigest()
|
|
|
|
|
|
|
|
|
|
|
|
def md5(self, filename):
|
|
|
|
def md5(self, filename):
|
|
|
|
|