From 7827b687fa022e86a2643e7a1951af8c7e80608c Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sat, 22 Jul 2023 15:44:45 +0200 Subject: [PATCH] feat: ability to define zip compression level --- backend/prisma/seed/config.seed.ts | 7 ++++--- backend/src/share/share.service.ts | 2 +- frontend/src/components/share/DownloadAllButton.tsx | 2 +- frontend/src/i18n/translations/en-US.ts | 3 +++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/prisma/seed/config.seed.ts b/backend/prisma/seed/config.seed.ts index 8b2dbf223..b7a78f4bb 100644 --- a/backend/prisma/seed/config.seed.ts +++ b/backend/prisma/seed/config.seed.ts @@ -18,7 +18,6 @@ const configVariables: ConfigVariables = { appUrl: { type: "string", defaultValue: "http://localhost:3000", - secret: false, }, showHomePage: { @@ -36,15 +35,17 @@ const configVariables: ConfigVariables = { allowUnauthenticatedShares: { type: "boolean", defaultValue: "false", - secret: false, }, maxSize: { type: "number", defaultValue: "1000000000", - secret: false, }, + zipCompressionLevel: { + type: "number", + defaultValue: "9", + }, }, email: { enableShareEmailRecipients: { diff --git a/backend/src/share/share.service.ts b/backend/src/share/share.service.ts index b75218be2..4ab835079 100644 --- a/backend/src/share/share.service.ts +++ b/backend/src/share/share.service.ts @@ -104,7 +104,7 @@ export class ShareService { const files = await this.prisma.file.findMany({ where: { shareId } }); const archive = archiver("zip", { - zlib: { level: 9 }, + zlib: { level: this.config.get("share.zipCompressionLevel") }, }); const writeStream = fs.createWriteStream(`${path}/archive.zip`); diff --git a/frontend/src/components/share/DownloadAllButton.tsx b/frontend/src/components/share/DownloadAllButton.tsx index f10c28d5e..f5e581a62 100644 --- a/frontend/src/components/share/DownloadAllButton.tsx +++ b/frontend/src/components/share/DownloadAllButton.tsx @@ -49,7 +49,7 @@ const DownloadAllButton = ({ shareId }: { shareId: string }) => { } }} > - + ); }; diff --git a/frontend/src/i18n/translations/en-US.ts b/frontend/src/i18n/translations/en-US.ts index a74c3999a..6804b7f10 100644 --- a/frontend/src/i18n/translations/en-US.ts +++ b/frontend/src/i18n/translations/en-US.ts @@ -386,6 +386,9 @@ export default { "Whether unauthenticated users can create shares", "admin.config.share.max-size": "Max size", "admin.config.share.max-size.description": "Maximum share size in bytes", + "admin.config.share.zip-compression-level": "Zip compression level", + "admin.config.share.zip-compression-level.description": + "Adjust the level to balance between file size and compression speed. Valid values range from 0 to 9, with 0 being no compression and 9 being maximum compression. ", "admin.config.smtp.enabled": "Enabled", "admin.config.smtp.enabled.description":