Commit 1b38bd8a by Brian Coca

fixed issue with tmp file (path can include filename) and added missing

else which made it try to link x2
parent 6e6ad972
...@@ -301,7 +301,7 @@ def main(): ...@@ -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,13 +311,14 @@ def main(): ...@@ -311,13 +311,14 @@ 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))
try: else:
if state == 'hard': try:
os.link(src,path) if state == 'hard':
else: os.link(src,path)
os.symlink(src, path) else:
except OSError, e: os.symlink(src, path)
module.fail_json(path=path, msg='Error while linking: %s' % str(e)) except OSError, e:
module.fail_json(path=path, msg='Error while linking: %s' % str(e))
changed = module.set_fs_attributes_if_different(file_args, changed) changed = module.set_fs_attributes_if_different(file_args, changed)
module.exit_json(dest=path, src=src, changed=changed) module.exit_json(dest=path, src=src, changed=changed)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment