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:
parent
db36c41c3b
commit
2cc4ac2e75
1 changed files with 8 additions and 5 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue