diff options
author | zuiurs <z11111001011@gmail.com> | 2016-10-31 16:47:55 +0900 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2016-11-03 11:28:21 -0700 |
commit | 64314c8e98475d6c954a8c12a46be13735231572 (patch) | |
tree | f53c098fe48465ac4cb80e7f1baf3ee63b2e19c1 | |
parent | 164225aa43e1c57fc97d9520aa34eec532edacea (diff) | |
download | ansible-modules-core-64314c8e98475d6c954a8c12a46be13735231572.tar.gz |
fix the behavior that the dest is directory
This fixes the behavior that the dest is directory,
when we set the "force: no" argument.
To be join the dest and the src's basename,
before checking the "force" argument.
(cherry picked from commit cb1d90ccfd2f3ed62fc8fb1e6620463f5c9c15fe)
-rw-r--r-- | files/copy.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/files/copy.py b/files/copy.py index 90662265..d42c285e 100644 --- a/files/copy.py +++ b/files/copy.py @@ -284,18 +284,19 @@ def main(): directory_args['mode'] = None adjust_recursive_directory_permissions(pre_existing_dir, new_directory_list, module, directory_args, changed) + if os.path.isdir(b_dest): + basename = os.path.basename(src) + if original_basename: + basename = original_basename + dest = os.path.join(dest, basename) + b_dest = to_bytes(dest, errors='surrogate_or_strict') + if os.path.exists(b_dest): if os.path.islink(b_dest) and follow: b_dest = os.path.realpath(b_dest) dest = to_native(b_dest, errors='surrogate_or_strict') if not force: module.exit_json(msg="file already exists", src=src, dest=dest, changed=False) - if os.path.isdir(b_dest): - basename = os.path.basename(src) - if original_basename: - basename = original_basename - dest = os.path.join(dest, basename) - b_dest = to_bytes(dest, errors='surrogate_or_strict') if os.access(b_dest, os.R_OK): checksum_dest = module.sha1(dest) else: |