mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
We don't mind writing empty files if the original file doesn't exist.
This commit is contained in:
parent
8b780ecc81
commit
1f874cf918
@ -702,8 +702,11 @@ class AtomicFile(file):
|
||||
def close(self):
|
||||
if not self.rolledback:
|
||||
super(AtomicFile, self).close()
|
||||
# We don't mind writing an empty file if the file we're overwriting
|
||||
# doesn't exist.
|
||||
size = os.path.getsize(self.tempFilename)
|
||||
if size or self.allowEmptyOverwrite:
|
||||
originalExists = os.path.exists(self.filename)
|
||||
if size or self.allowEmptyOverwrite or not originalExists:
|
||||
if os.path.exists(self.tempFilename):
|
||||
# We use shutil.move here instead of os.rename because
|
||||
# the latter doesn't work on Windows when self.filename
|
||||
|
Loading…
Reference in New Issue
Block a user