]> git.ipfire.org Git - pbs.git/commitdiff
uploads: Don't delete successful uploads
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 17:39:53 +0000 (17:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Jul 2025 17:39:53 +0000 (17:39 +0000)
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>
src/buildservice/uploads.py

index 7bca4d9a35b28a14b4e3f09d4905e3b9fca54557..44b709fc97781ff01a636c6c28605b0195cdca2a 100644 (file)
@@ -316,13 +316,17 @@ class UploadStream(object):
                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)