]> git.ipfire.org Git - pakfire.git/commitdiff
daemon: Upload the log after the build has finished
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Oct 2022 17:57:10 +0000 (17:57 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Oct 2022 17:57:10 +0000 (17:57 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/daemon.py

index a6bb9ff4745d4974a6ce611e72790f90d4fd01e5..c78e4440138ead0326c817d26462c8e3249d7a49 100644 (file)
@@ -247,12 +247,20 @@ class Worker(multiprocessing.Process):
                await self.job.status("building")
 
                # Run the build
-               build = self._build(pkg, arch=arch,
-                       logger=logger._log, build_id=job_id)
+               try:
+                       build = self._build(pkg, arch=arch,
+                               logger=logger._log, build_id=job_id)
+
+                       # Wait until the build process is done and stream the log in the meantime
+                       while not build.done():
+                               await logger.stream(timeout=1)
 
-               # Wait until the build process is done and stream the log in the meantime
-               while not build.done():
-                       await logger.stream(timeout=1)
+               finally:
+                       # Upload the build log
+                       log_upload_id = await self.hub.upload(
+                               logger.logfile.name,
+                               filename="%s.log" % job_id,
+                       )
 
        def _build(self, pkg, arch=None, logger=None, **kwargs):
                """
@@ -327,7 +335,7 @@ class BuildLogger(object):
                self.job = job
 
                # Create a logfile
-               self.logfile = tempfile.SpooledTemporaryFile(mode="w+", max_size=1048576)
+               self.logfile = tempfile.NamedTemporaryFile()
 
                # Create a FIFO queue to buffer any log messages
                self.queue = asyncio.Queue()