The delete_on_close flag is doing something different from what I
throught and therefore we will have to handle this ourselves.
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
if type is None:
return await self.close()
+ # If there was an exception, we delete the file
+ if self.f:
+ await self.backend.unlink(self.f.name)
+
async def write(self, chunk):
"""
Writes a chunk to the file and puts it into the hasher, too.
"""
# Open a temporary file unless already done so (we cannot do this in the constructor)
if self.f is None:
- self.f = await self.backend.tempfile(prefix="upload-", delete_on_close=False)
+ self.f = await self.backend.tempfile(prefix="upload-", delete=False)
# Write the chunk
await self.f.write(chunk)