import asyncio
import datetime
+import gzip
import hashlib
import logging
import os
"jobs",
self.uuid[0:2],
self.uuid[2:4],
- "%s.log" % self.uuid[4:],
+ "%s.log.gz" % self.uuid[4:],
)
- # Copy file to its destination
- await self.backend.copy(upload.path, path)
+ # Open the destination path
+ with gzip.open(path, "wb", compresslevel=9) as f:
+ await upload.copyinto(f)
# Compute a digest for integrity
digest = await upload.digest("blake2s")
# Return the digest
return h.digest()
+
+ async def copyinto(self, dst):
+ """
+ Copies the content of this upload into the destination file descriptor.
+ """
+ return await asyncio.to_thread(self._copyinfo, dst)
+
+ def _copyinto(self, dst):
+ # Open the source file and copy it into the destination file descriptor
+ with open(self.path, "rb") as src:
+ shutil.copyfileobj(src, dst)