mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 05:40:23 -07:00
Fix copy for implicit relative paths (#35016)
copy currently fails if you specify a destination without any directory component. This is because we take the dirname of the destination for some processing and no dirname causes issues. This corrects that by prepending "./" if there is no directory component in dest.
This commit is contained in:
parent
2a0adaf542
commit
8a22b51755
2 changed files with 58 additions and 0 deletions
|
@ -218,6 +218,7 @@ state:
|
|||
'''
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import shutil
|
||||
import tempfile
|
||||
import traceback
|
||||
|
@ -279,6 +280,9 @@ def main():
|
|||
src = module.params['src']
|
||||
b_src = to_bytes(src, errors='surrogate_or_strict')
|
||||
dest = module.params['dest']
|
||||
# Make sure we always have a directory component for later processing
|
||||
if os.path.sep not in dest:
|
||||
dest = '.{0}{1}'.format(os.path.sep, dest)
|
||||
b_dest = to_bytes(dest, errors='surrogate_or_strict')
|
||||
backup = module.params['backup']
|
||||
force = module.params['force']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue