1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Catch traceback caused by permissions errors during a local md5 sum

Fixes #6948
This commit is contained in:
James Cammarata 2014-04-14 12:36:54 -05:00
parent db36c41c3b
commit 2cc4ac2e75

View file

@ -590,12 +590,15 @@ def md5(filename):
return None
digest = _md5()
blocksize = 64 * 1024
infile = open(filename, 'rb')
block = infile.read(blocksize)
while block:
digest.update(block)
try:
infile = open(filename, 'rb')
block = infile.read(blocksize)
infile.close()
while block:
digest.update(block)
block = infile.read(blocksize)
infile.close()
except IOError, e:
raise errors.AnsibleError("error while accessing the file %s, error was: %s" % (filename, e))
return digest.hexdigest()
def default(value, function):