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:
@@ -335,13 +335,10 @@ class PathFormat():
|
|||||||
|
|
||||||
if self.temppath != self.realpath:
|
if self.temppath != self.realpath:
|
||||||
# Move temp file to its actual location
|
# Move temp file to its actual location
|
||||||
|
os.makedirs(self.realdirectory, exist_ok=True)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
os.replace(self.temppath, self.realpath)
|
os.replace(self.temppath, self.realpath)
|
||||||
except FileNotFoundError:
|
|
||||||
# delayed directory creation
|
|
||||||
os.makedirs(self.realdirectory)
|
|
||||||
continue
|
|
||||||
except OSError:
|
except OSError:
|
||||||
# move across different filesystems
|
# move across different filesystems
|
||||||
shutil.copyfile(self.temppath, self.realpath)
|
shutil.copyfile(self.temppath, self.realpath)
|
||||||
|
|||||||
Reference in New Issue
Block a user