path.py - fix system cannot move file to different drive

This fixes the below error message:

OSError(18, 'The system cannot move the file to a different disk drive')
This commit is contained in:
AyluinReymaer
2024-06-29 00:08:53 +01:00
committed by GitHub
parent ea81fa985f
commit 91a989a172

View File

@@ -335,13 +335,10 @@ class PathFormat():
if self.temppath != self.realpath:
# Move temp file to its actual location
os.makedirs(self.realdirectory, exist_ok=True)
while True:
try:
os.replace(self.temppath, self.realpath)
except FileNotFoundError:
# delayed directory creation
os.makedirs(self.realdirectory)
continue
except OSError:
# move across different filesystems
shutil.copyfile(self.temppath, self.realpath)