File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,12 @@ def move_file(
8282 rel_dst = frombase (common , dst_syspath )
8383 with _src_fs .lock (), _dst_fs .lock ():
8484 with OSFS (common ) as base :
85- base .move (rel_src , rel_dst , preserve_time = preserve_time )
85+ base .move (
86+ rel_src ,
87+ rel_dst ,
88+ overwrite = True ,
89+ preserve_time = preserve_time ,
90+ )
8691 return # optimization worked, exit early
8792 except ValueError :
8893 # This is raised if we cannot find a common base folder.
Original file line number Diff line number Diff line change @@ -151,6 +151,14 @@ def test_move_file_read_only_mem_dest(self):
151151 dst_ro .exists ("target.txt" ), "file should not have been copied over"
152152 )
153153
154+ def test_overwrite (self ):
155+ with open_fs ("temp://" ) as src , open_fs ("temp://" ) as dst :
156+ src .writetext ("file.txt" , "Content" )
157+ dst .writetext ("target.txt" , "Content" )
158+ fs .move .move_file (src , "file.txt" , dst , "target.txt" )
159+ self .assertFalse (src .exists ("file.txt" ))
160+ self .assertTrue (dst .exists ("target.txt" ))
161+
154162 @parameterized .expand ([(True ,), (False ,)])
155163 def test_move_file_cleanup_on_error (self , cleanup ):
156164 with open_fs ("mem://" ) as src , open_fs ("mem://" ) as dst :
You can’t perform that action at this time.
0 commit comments