mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
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.
This commit is contained in:
@@ -284,18 +284,19 @@ def main():
|
|||||||
directory_args['mode'] = None
|
directory_args['mode'] = None
|
||||||
adjust_recursive_directory_permissions(pre_existing_dir, new_directory_list, module, directory_args, changed)
|
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.exists(b_dest):
|
||||||
if os.path.islink(b_dest) and follow:
|
if os.path.islink(b_dest) and follow:
|
||||||
b_dest = os.path.realpath(b_dest)
|
b_dest = os.path.realpath(b_dest)
|
||||||
dest = to_native(b_dest, errors='surrogate_or_strict')
|
dest = to_native(b_dest, errors='surrogate_or_strict')
|
||||||
if not force:
|
if not force:
|
||||||
module.exit_json(msg="file already exists", src=src, dest=dest, changed=False)
|
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):
|
if os.access(b_dest, os.R_OK):
|
||||||
checksum_dest = module.sha1(dest)
|
checksum_dest = module.sha1(dest)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user