fix 'part-directory' (#2576)

bug introduced in 99cb2872
pull/2584/head
Mike Fährmann 2 years ago
parent feb470d19a
commit 9c8647a4fd
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -317,11 +317,18 @@ class PathFormat():
if self.temppath != self.realpath:
# Move temp file to its actual location
try:
os.replace(self.temppath, self.realpath)
except OSError:
shutil.copyfile(self.temppath, self.realpath)
os.unlink(self.temppath)
while True:
try:
os.replace(self.temppath, self.realpath)
except FileNotFoundError:
# delayed directory creation
os.makedirs(self.realdirectory, exist_ok=True)
continue
except OSError:
# move across different filesystems
shutil.copyfile(self.temppath, self.realpath)
os.unlink(self.temppath)
break
mtime = self.kwdict.get("_mtime")
if mtime:

Loading…
Cancel
Save