"kinit", "-k", "-t", keytab, principal,
)
+ async def copy(self, src, dst):
+ """
+ Copies a file from src to dst
+ """
+ log.debug("Copying %s to %s" % (src, dst))
+
+ path = os.path.dirname(dst)
+
+ # Create destination path (if it does not exist)
+ try:
+ await asyncio.to_thread(os.makedirs, path)
+ except FileExistsError:
+ pass
+
+ # Copy data without any metadata
+ await asyncio.to_thread(shutil.copyfile, src, dst)
+
def _write_tempfile(self, content):
"""
Writes the content to a temporary file and returns its path
STATICDIR = "@staticdir@"
PAKFIRE_DIR = "/pub/pakfire"
+LOGS_DIR = os.path.join(PAKFIRE_DIR, "logs")
PACKAGES_DIR = os.path.join(PAKFIRE_DIR, "packages")
REPOS_DIR = os.path.join(PAKFIRE_DIR, "repos")
SOURCES_DIR = os.path.join(PAKFIRE_DIR, "sources")
# Store the time
self._set_attribute_now("started_at")
- def finished(self, success, message=None):
+ async def finished(self, success, message=None, log=None):
"""
Called when this job has finished
"""
# Store the time
self._set_attribute_now("finished_at")
+ # Import log
+ if log:
+ await self._import_log(log)
+
# Did this build fail?
if not success:
# Clone the build
return job
+ async def _import_log(self, upload):
+ # Create some destination path
+ path = os.path.join(
+ LOGS_DIR,
+ "jobs",
+ self.uuid[0:2],
+ self.uuid[2:4],
+ "%s.log" % self.uuid[4:],
+ )
+
+ # Copy file to its destination
+ await self.backend.copy(upload.path, path)
+
+ # Compute a digest for integrity
+ digest = await upload.digest("blake2s")
+
+ # Store everything in the database
+ self._set_attribute("log_path", path)
+ self._set_attribute("log_size", upload.size)
+ self._set_attribute("log_digest_blake2s", digest)
+
# Builder
@lazy_property