Ensure we don't atomically write an empty file

This commit is contained in:
miruka
2020-03-17 12:09:08 -04:00
parent 9a66afb4eb
commit e4d47b9b9c
3 changed files with 36 additions and 11 deletions

View File

@@ -90,8 +90,9 @@ class DataFile:
if not self.create_missing and not self.path.exists():
continue
async with atomic_write(self.path) as new:
async with atomic_write(self.path) as (new, done):
await new.write(self._to_write)
done()
self._to_write = None