mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-03 04:34:24 -07:00
Only unlink the symlink tempfile on error if it was created in the
previous operation.
This commit is contained in:
parent
2156e87e62
commit
e157355fd6
1 changed files with 2 additions and 1 deletions
|
@ -305,6 +305,7 @@ def main():
|
||||||
os.symlink(src, tmppath)
|
os.symlink(src, tmppath)
|
||||||
os.rename(tmppath, path)
|
os.rename(tmppath, path)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
|
if os.path.exists(tmppath):
|
||||||
os.unlink(tmppath)
|
os.unlink(tmppath)
|
||||||
module.fail_json(path=path, msg='Error while replacing: %s' % str(e))
|
module.fail_json(path=path, msg='Error while replacing: %s' % str(e))
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue