mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Avoid crash in module_common when the file cannot be moved/copy
This commit is contained in:
parent
dbfad567bc
commit
8217e0706f
1 changed files with 2 additions and 2 deletions
|
@ -815,7 +815,7 @@ class AnsibleModule(object):
|
||||||
self.fail_json(msg='Could not make backup of %s to %s: %s' % (fn, backupdest, e))
|
self.fail_json(msg='Could not make backup of %s to %s: %s' % (fn, backupdest, e))
|
||||||
return backupdest
|
return backupdest
|
||||||
|
|
||||||
def cleanup(tmpfile):
|
def cleanup(self,tmpfile):
|
||||||
if os.path.exists(tmpfile):
|
if os.path.exists(tmpfile):
|
||||||
try:
|
try:
|
||||||
os.unlink(tmpfile)
|
os.unlink(tmpfile)
|
||||||
|
@ -856,7 +856,7 @@ class AnsibleModule(object):
|
||||||
# rename might not preserve context
|
# rename might not preserve context
|
||||||
self.set_context_if_different(dest, context, False)
|
self.set_context_if_different(dest, context, False)
|
||||||
except (shutil.Error, OSError, IOError), e:
|
except (shutil.Error, OSError, IOError), e:
|
||||||
cleanup(tmp_dest)
|
self.cleanup(tmp_dest)
|
||||||
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e))
|
self.fail_json(msg='Could not replace file: %s to %s: %s' % (src, dest, e))
|
||||||
|
|
||||||
def run_command(self, args, check_rc=False, close_fds=False, executable=None, data=None):
|
def run_command(self, args, check_rc=False, close_fds=False, executable=None, data=None):
|
||||||
|
|
Loading…
Reference in a new issue