File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -792,7 +792,12 @@ def safe_copy(src: FileInfo, dst: FileInfo) -> None:
792
792
793
793
try :
794
794
if dst .basename != src .basename :
795
- rm (dst .path , glob = False )
795
+ if dst .stat is not None :
796
+ # Case in which the destination file exists but does
797
+ # not have the same casing. In that case we delete the
798
+ # target file and redo a copy. This occurs for example
799
+ # on Windos with NTFS.
800
+ rm (dst .path , glob = False )
796
801
dst = FileInfo (
797
802
os .path .join (os .path .dirname (dst .path ), src .basename ),
798
803
None ,
@@ -803,7 +808,8 @@ def safe_copy(src: FileInfo, dst: FileInfo) -> None:
803
808
with open (dst .path , "wb" ) as fdst :
804
809
shutil .copyfileobj (fsrc , fdst )
805
810
except OSError :
806
- rm (dst .path , glob = False )
811
+ if dst .stat is not None :
812
+ rm (dst .path , glob = False )
807
813
with open (src .path , "rb" ) as fsrc :
808
814
with open (dst .path , "wb" ) as fdst :
809
815
shutil .copyfileobj (fsrc , fdst )
You can’t perform that action at this time.
0 commit comments