@ -518,7 +518,7 @@ def copy_common_dirs(src, dest, module):
changed = True
changed = True
# recurse into subdirectory
# recurse into subdirectory
changed = c hanged or c opy_common_dirs( os . path . join ( src , item ) , os . path . join ( dest , item ) , module )
changed = c opy_common_dirs( os . path . join ( src , item ) , os . path . join ( dest , item ) , module ) or changed
return changed
return changed
@ -616,6 +616,7 @@ def main():
module . fail_json ( * * e . results )
module . fail_json ( * * e . results )
os . makedirs ( b_dirname )
os . makedirs ( b_dirname )
changed = True
directory_args = module . load_file_common_arguments ( module . params )
directory_args = module . load_file_common_arguments ( module . params )
directory_mode = module . params [ " directory_mode " ]
directory_mode = module . params [ " directory_mode " ]
if directory_mode is not None :
if directory_mode is not None :
@ -744,8 +745,6 @@ def main():
except ( IOError , OSError ) :
except ( IOError , OSError ) :
module . fail_json ( msg = " failed to copy: %s to %s " % ( src , dest ) , traceback = traceback . format_exc ( ) )
module . fail_json ( msg = " failed to copy: %s to %s " % ( src , dest ) , traceback = traceback . format_exc ( ) )
changed = True
changed = True
else :
changed = False
# If neither have checksums, both src and dest are directories.
# If neither have checksums, both src and dest are directories.
if checksum_src is None and checksum_dest is None :
if checksum_src is None and checksum_dest is None :
@ -793,13 +792,12 @@ def main():
b_dest = to_bytes ( os . path . join ( b_dest , b_basename ) , errors = ' surrogate_or_strict ' )
b_dest = to_bytes ( os . path . join ( b_dest , b_basename ) , errors = ' surrogate_or_strict ' )
if not module . check_mode and not os . path . exists ( b_dest ) :
if not module . check_mode and not os . path . exists ( b_dest ) :
os . makedirs ( b_dest )
os . makedirs ( b_dest )
changed = True
b_src = to_bytes ( os . path . join ( module . params [ ' src ' ] , " " ) , errors = ' surrogate_or_strict ' )
b_src = to_bytes ( os . path . join ( module . params [ ' src ' ] , " " ) , errors = ' surrogate_or_strict ' )
diff_files_changed = copy_diff_files ( b_src , b_dest , module )
diff_files_changed = copy_diff_files ( b_src , b_dest , module )
left_only_changed = copy_left_only ( b_src , b_dest , module )
left_only_changed = copy_left_only ( b_src , b_dest , module )
common_dirs_changed = copy_common_dirs ( b_src , b_dest , module )
common_dirs_changed = copy_common_dirs ( b_src , b_dest , module )
owner_group_changed = chown_recursive ( b_dest , module )
owner_group_changed = chown_recursive ( b_dest , module )
if diff_files_changed or left_only_changed or common_dirs_changed or owner_group_changed :
changed = True
if module . check_mode and not os . path . exists ( b_dest ) :
if module . check_mode and not os . path . exists ( b_dest ) :
changed = True
changed = True