@@ -151,7 +151,6 @@ def copy_file(
151151 src_path , dst_path , overwrite = True , preserve_time = preserve_time
152152 )
153153 else :
154- # TODO(preserve_time)
155154 # Standard copy
156155 with _src_fs .lock (), _dst_fs .lock ():
157156 if _dst_fs .hassyspath (dst_path ):
@@ -160,6 +159,7 @@ def copy_file(
160159 else :
161160 with _src_fs .openbin (src_path ) as read_file :
162161 _dst_fs .upload (dst_path , read_file )
162+ copy_metadata (_src_fs , src_path , _dst_fs , dst_path )
163163
164164
165165def copy_file_internal (
@@ -190,14 +190,17 @@ def copy_file_internal(
190190 # Same filesystem, so we can do a potentially optimized
191191 # copy
192192 src_fs .copy (src_path , dst_path , overwrite = True , preserve_time = preserve_time )
193- # TODO(preserve_time)
194- elif dst_fs .hassyspath (dst_path ):
193+ return
194+
195+ if dst_fs .hassyspath (dst_path ):
195196 with dst_fs .openbin (dst_path , "w" ) as write_file :
196197 src_fs .download (src_path , write_file )
197198 else :
198199 with src_fs .openbin (src_path ) as read_file :
199200 dst_fs .upload (dst_path , read_file )
200201
202+ copy_metadata (src_fs , src_path , dst_fs , dst_path )
203+
201204
202205def copy_file_if_newer (
203206 src_fs , # type: Union[FS, Text]
@@ -326,9 +329,10 @@ def dst():
326329 from ._bulk import Copier
327330
328331 with src () as _src_fs , dst () as _dst_fs :
329- with _src_fs .lock (), _dst_fs .lock ():
330- _thread_safe = is_thread_safe (_src_fs , _dst_fs )
331- with Copier (num_workers = workers if _thread_safe else 0 ) as copier :
332+ _thread_safe = is_thread_safe (_src_fs , _dst_fs )
333+ copier = Copier (num_workers = workers if _thread_safe else 0 )
334+ with copier :
335+ with _src_fs .lock (), _dst_fs .lock ():
332336 _dst_fs .makedir (_dst_path , recreate = True )
333337 for dir_path , dirs , files in walker .walk (_src_fs , _src_path ):
334338 copy_path = combine (_dst_path , frombase (_src_path , dir_path ))
@@ -345,6 +349,7 @@ def dst():
345349 preserve_time = preserve_time ,
346350 )
347351 on_copy (_src_fs , src_path , _dst_fs , dst_path )
352+ pass
348353
349354
350355def copy_dir_if_newer (
@@ -438,3 +443,25 @@ def dst():
438443 preserve_time = preserve_time ,
439444 )
440445 on_copy (_src_fs , dir_path , _dst_fs , copy_path )
446+
447+
448+ def copy_metadata (
449+ src_fs , # type: Union[FS, Text]
450+ src_path , # type: Text
451+ dst_fs , # type: Union[FS, Text]
452+ dst_path , # type: Text
453+ ):
454+ # type: (...) -> None
455+ """Copies metadata from one file to another.
456+
457+ Arguments:
458+ src_fs (FS or str): Source filesystem (instance or URL).
459+ src_path (str): Path to a directory on the source filesystem.
460+ dst_fs (FS or str): Destination filesystem (instance or URL).
461+ dst_path (str): Path to a directory on the destination filesystem.
462+
463+ """
464+ # TODO(preserve_time)
465+ with manage_fs (src_fs , writeable = False ) as _src_fs :
466+ with manage_fs (dst_fs , create = True ) as _dst_fs :
467+ pass
0 commit comments