Commit 8b50ad7e by Michael DeHaan

Fix for atomic_replace patch if file does not yet exist

parent 7a8009f9
...@@ -596,6 +596,7 @@ class AnsibleModule(object): ...@@ -596,6 +596,7 @@ class AnsibleModule(object):
def atomic_replace(self, src, dest): def atomic_replace(self, src, dest):
'''atomically replace dest with src, copying attributes from dest''' '''atomically replace dest with src, copying attributes from dest'''
if os.path.exists(dest):
st = os.stat(dest) st = os.stat(dest)
os.chmod(src, st.st_mode & 07777) os.chmod(src, st.st_mode & 07777)
try: try:
...@@ -608,7 +609,6 @@ class AnsibleModule(object): ...@@ -608,7 +609,6 @@ class AnsibleModule(object):
self.set_context_if_different(src, context, False) self.set_context_if_different(src, context, False)
os.rename(src, dest) os.rename(src, dest)
# == END DYNAMICALLY INSERTED CODE === # == END DYNAMICALLY INSERTED CODE ===
""" """
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