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
|
return None
|
||||||
digest = _md5()
|
digest = _md5()
|
||||||
blocksize = 64 * 1024
|
blocksize = 64 * 1024
|
||||||
infile = open(filename, 'rb')
|
try:
|
||||||
block = infile.read(blocksize)
|
infile = open(filename, 'rb')
|
||||||
while block:
|
|
||||||
digest.update(block)
|
|
||||||
block = infile.read(blocksize)
|
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()
|
return digest.hexdigest()
|
||||||
|
|
||||||
def default(value, function):
|
def default(value, function):
|
||||||
|
|
Loading…
Reference in a new issue