From e719bf765d49ac7ac14ae056bfe0605756651259 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 3 Apr 2015 09:20:19 -0400 Subject: [PATCH] switched to use cross platform os.sep, added diff output to copy --- v2/ansible/plugins/action/copy.py | 12 +++++------- v2/ansible/plugins/action/fetch.py | 2 +- v2/ansible/plugins/action/template.py | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/v2/ansible/plugins/action/copy.py b/v2/ansible/plugins/action/copy.py index 89c2fde7b3..ece8b5b11b 100644 --- a/v2/ansible/plugins/action/copy.py +++ b/v2/ansible/plugins/action/copy.py @@ -31,7 +31,7 @@ from ansible.plugins.action import ActionBase from ansible.utils.boolean import boolean from ansible.utils.hashing import checksum from ansible.utils.unicode import to_bytes - +from ansible.parsing.vault import VaultLib class ActionModule(ActionBase): @@ -55,7 +55,7 @@ class ActionModule(ActionBase): # Check if the source ends with a "/" source_trailing_slash = False if source: - source_trailing_slash = source.endswith("/") + source_trailing_slash = source.endswith(os.sep) # Define content_tempfile in case we set it after finding content populated. content_tempfile = None @@ -145,6 +145,7 @@ class ActionModule(ActionBase): dest = self._remote_expand_user(dest, tmp) for source_full, source_rel in source_files: + # Generate a hash of the local file. local_checksum = checksum(source_full) @@ -284,11 +285,8 @@ class ActionModule(ActionBase): else: result = dict(dest=dest, src=source, changed=changed) - # FIXME: move diffs into the result? - #if len(diffs) == 1: - # return ReturnData(conn=conn, result=result, diff=diffs[0]) - #else: - # return ReturnData(conn=conn, result=result) + if len(diffs) == 1: + result['diff']=diffs[0] return result diff --git a/v2/ansible/plugins/action/fetch.py b/v2/ansible/plugins/action/fetch.py index e63fd88ea5..7b549f5ecb 100644 --- a/v2/ansible/plugins/action/fetch.py +++ b/v2/ansible/plugins/action/fetch.py @@ -82,7 +82,7 @@ class ActionModule(ActionBase): dest = os.path.expanduser(dest) if flat: - if dest.endswith("/"): + if dest.endswith(os.sep): # if the path ends with "/", we'll use the source filename as the # destination filename base = os.path.basename(source_local) diff --git a/v2/ansible/plugins/action/template.py b/v2/ansible/plugins/action/template.py index 1f7a6955a3..76b2e78a73 100644 --- a/v2/ansible/plugins/action/template.py +++ b/v2/ansible/plugins/action/template.py @@ -91,7 +91,7 @@ class ActionModule(ActionBase): dest = self._remote_expand_user(dest, tmp) directory_prepended = False - if dest.endswith("/"): # CCTODO: Fix path for Windows hosts. + if dest.endswith(os.sep): directory_prepended = True base = os.path.basename(source) dest = os.path.join(dest, base)