mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixed issue with tmp file (path can include filename) and added missing
else which made it try to link x2
This commit is contained in:
parent
6e6ad97239
commit
1b38bd8a40
1 changed files with 9 additions and 8 deletions
|
@ -301,7 +301,7 @@ def main():
|
||||||
if changed and not module.check_mode:
|
if changed and not module.check_mode:
|
||||||
if prev_state != 'absent':
|
if prev_state != 'absent':
|
||||||
# try to replace atomically
|
# try to replace atomically
|
||||||
tmppath = ".%s.%s.%s.tmp" % (path,os.getpid(),time.time())
|
tmppath = '/'.join([os.path.dirname(path), ".%s.%s.tmp" % (os.getpid(),time.time())])
|
||||||
try:
|
try:
|
||||||
if state == 'hard':
|
if state == 'hard':
|
||||||
os.link(src,tmppath)
|
os.link(src,tmppath)
|
||||||
|
@ -311,6 +311,7 @@ def main():
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
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))
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
if state == 'hard':
|
if state == 'hard':
|
||||||
os.link(src,path)
|
os.link(src,path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue