Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
await self.backend.make_parent_directory(path)
# Open the destination path
- with gzip.open(path, "wb", compresslevel=9) as f:
+ f = open(path, "wb")
+
+ # If the upload was not compressed already, compress it
+ if not upload.extension == "gz":
+ f = gzip.GzipFile(fileobj=f, compresslevel=9)
+
+ # Copy the payload
+ with f:
await upload.copyinto(f)
# Store everything in the database
filename = Column(Text, nullable=False)
+ # Extension
+
+ @property
+ def extension(self):
+ filename, ext = os.path.splitext(self.filename)
+
+ return ext.removeprefix(".")
+
# Path
path = Column(Text, nullable=False)