From 3d1d4d0fc7c0351724387c3721280c334ae94d98 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sun, 11 Dec 2022 12:19:42 +0100 Subject: [PATCH] fix: only create zip if more than one file is in the share --- backend/src/share/share.service.ts | 7 ++++--- frontend/src/pages/share/[shareId].tsx | 18 ++++++++---------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/backend/src/share/share.service.ts b/backend/src/share/share.service.ts index 2d33997..22273e3 100644 --- a/backend/src/share/share.service.ts +++ b/backend/src/share/share.service.ts @@ -105,9 +105,10 @@ export class ShareService { ); // Asynchronously create a zip of all files - this.createZip(id).then(() => - this.prisma.share.update({ where: { id }, data: { isZipReady: true } }) - ); + if (share.files.length > 1) + this.createZip(id).then(() => + this.prisma.share.update({ where: { id }, data: { isZipReady: true } }) + ); // Send email for each recepient for (const recepient of share.recipients) { diff --git a/frontend/src/pages/share/[shareId].tsx b/frontend/src/pages/share/[shareId].tsx index 2555f79..7e2f9b7 100644 --- a/frontend/src/pages/share/[shareId].tsx +++ b/frontend/src/pages/share/[shareId].tsx @@ -17,7 +17,7 @@ export function getServerSideProps(context: GetServerSidePropsContext) { const Share = ({ shareId }: { shareId: string }) => { const modals = useModals(); - const [fileList, setFileList] = useState([]); + const [files, setFiles] = useState([]); const getShareToken = async (password?: string) => { await shareService @@ -41,7 +41,7 @@ const Share = ({ shareId }: { shareId: string }) => { shareService .get(shareId) .then((share) => { - setFileList(share.files); + setFiles(share.files); }) .catch((e) => { const { error } = e.response.data; @@ -77,14 +77,12 @@ const Share = ({ shareId }: { shareId: string }) => { title={`Share ${shareId}`} description="Look what I've shared with you." /> - - - - + {files.length > 1 && ( + + + + )} + ); };