tmp file clean up in file.manage - fix for #33708

This commit is contained in:
Eric Cook 2016-12-03 01:15:59 -05:00
parent 723699fda9
commit 48c4ee6f31

View File

@ -2112,11 +2112,15 @@ def managed(name,
ret.update(cret)
if os.path.isfile(tmp_filename):
os.remove(tmp_filename)
if sfn and os.path.isfile(sfn):
os.remove(sfn)
return ret
# Since we generated a new tempfile and we are not returning here
# lets change the original sfn to the new tempfile or else we will
# get file not found
sfn = tmp_filename
if sfn and os.path.isfile(sfn):
os.remove(sfn)
sfn = tmp_filename
else:
ret = {'changes': {},
'comment': '',
@ -2158,6 +2162,8 @@ def managed(name,
finally:
if tmp_filename and os.path.isfile(tmp_filename):
os.remove(tmp_filename)
if sfn and os.path.isfile(sfn):
os.remove(sfn)
_RECURSE_TYPES = ['user', 'group', 'mode', 'ignore_files', 'ignore_dirs']