@@ -275,7 +275,7 @@ def download_s3_object(
275
275
if force or should_sync (
276
276
source_path = s3_path , destination_path = local_path , size_only = size_only , ** kwargs
277
277
):
278
- if local_path .exists () and not exist_ok :
278
+ if local_path .exists () and not exist_ok and not force :
279
279
raise ValueError (f"Unable to download S3 object to { local_path } . Path exists." )
280
280
elif local_path .exists () and local_path .is_dir () and exist_ok :
281
281
logger .warning (
@@ -1109,36 +1109,48 @@ def check_paths_in_sync(
1109
1109
"""
1110
1110
source_paths : Union [List [Path ], List [S3URI ]] = (
1111
1111
(
1112
- sorted ( map ( Path , find_paths (source_path , include_dirs = False )))
1112
+ [ Path ( p ) for p in sorted ( find_paths (source_path , include_dirs = False ))]
1113
1113
if source_path .is_dir ()
1114
1114
else [source_path ]
1115
1115
)
1116
1116
if isinstance (source_path , Path )
1117
1117
else (
1118
- list_s3_paths (source_path , ** kwargs ) if not is_object (source_path ) else [source_path ]
1118
+ sorted (list_s3_paths (source_path , ** kwargs )) # type: ignore[arg-type]
1119
+ if not is_object (source_path )
1120
+ else [source_path ] # type: ignore
1119
1121
)
1120
1122
)
1121
1123
destination_paths : Union [List [Path ], List [S3URI ]] = (
1122
1124
(
1123
- sorted (map (Path , find_paths (destination_path , include_dirs = False )))
1125
+ list (map (Path , sorted ( find_paths (destination_path , include_dirs = False ) )))
1124
1126
if destination_path .is_dir ()
1125
1127
else [destination_path ]
1126
1128
)
1127
1129
if isinstance (destination_path , Path )
1128
1130
else (
1129
- list_s3_paths (destination_path , ** kwargs )
1131
+ sorted ( list_s3_paths (destination_path , ** kwargs )) # type: ignore[arg-type]
1130
1132
if not is_object (destination_path )
1131
- else [destination_path ]
1133
+ else [destination_path ] # type: ignore
1132
1134
)
1133
1135
)
1134
1136
if len (source_paths ) == 0 :
1135
1137
raise ValueError (f"Source path { source_path } does not exist" )
1136
1138
if len (source_paths ) != len (destination_paths ):
1139
+ logger .info (
1140
+ "Source and destination paths have different number of paths. "
1141
+ f"Source path { source_path } has { len (source_paths )} paths, "
1142
+ f"destination path { destination_path } has { len (destination_paths )} paths"
1143
+ )
1137
1144
return False
1138
1145
for sp , dp in zip (source_paths , destination_paths ):
1139
1146
if str (sp ).removeprefix (str (source_path )) != str (dp ).removeprefix (str (destination_path )):
1147
+ logger .info (
1148
+ f"Source path { sp } (relative={ str (sp ).removeprefix (str (source_path ))} ) does not match "
1149
+ f"destination path { dp } (relative={ str (dp ).removeprefix (str (destination_path ))} )"
1150
+ )
1140
1151
return False
1141
1152
if should_sync (source_path = sp , destination_path = dp , size_only = size_only , ** kwargs ):
1153
+ logger .info (f"Source path { sp } content does not match destination path { dp } " )
1142
1154
return False
1143
1155
return True
1144
1156
0 commit comments