Use original_basename to set the dest path even if src is not set
This commit is contained in:
parent
fa6d74a970
commit
88b73afcbe
1 changed files with 10 additions and 8 deletions
|
@ -168,14 +168,6 @@ def main():
|
|||
# or copy module, even if this module never uses it, it is needed to key off some things
|
||||
if src is not None:
|
||||
src = os.path.expanduser(src)
|
||||
|
||||
# original_basename is used by other modules that depend on file.
|
||||
if os.path.isdir(path) and state not in ["link", "absent"]:
|
||||
if params['original_basename']:
|
||||
basename = params['original_basename']
|
||||
else:
|
||||
basename = os.path.basename(src)
|
||||
params['path'] = path = os.path.join(path, basename)
|
||||
else:
|
||||
if state in ['link','hard']:
|
||||
if follow:
|
||||
|
@ -184,6 +176,16 @@ def main():
|
|||
else:
|
||||
module.fail_json(msg='src and dest are required for creating links')
|
||||
|
||||
# original_basename is used by other modules that depend on file.
|
||||
if os.path.isdir(path) and state not in ["link", "absent"]:
|
||||
basename = None
|
||||
if params['original_basename']:
|
||||
basename = params['original_basename']
|
||||
elif src is not None:
|
||||
basename = os.path.basename(src)
|
||||
if basename:
|
||||
params['path'] = path = os.path.join(path, basename)
|
||||
|
||||
# make sure the target path is a directory when we're doing a recursive operation
|
||||
recurse = params['recurse']
|
||||
if recurse and state != 'directory':
|
||||
|
|
Loading…
Reference in a new issue