From 06234e42dfe25c31059f205ff3bc37d644db0d7c Mon Sep 17 00:00:00 2001 From: daniel31x13 Date: Fri, 28 Jun 2024 09:39:31 -0400 Subject: [PATCH] archive screenshots as jpeg instead of png + bug fix --- .../collections/collectionId/deleteCollectionById.ts | 2 ++ lib/api/controllers/users/userId/deleteUserById.ts | 2 +- lib/api/preservationScheme/handleScreenshotAndPdf.ts | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/api/controllers/collections/collectionId/deleteCollectionById.ts b/lib/api/controllers/collections/collectionId/deleteCollectionById.ts index 1ac1bf6..1e21809 100644 --- a/lib/api/controllers/collections/collectionId/deleteCollectionById.ts +++ b/lib/api/controllers/collections/collectionId/deleteCollectionById.ts @@ -58,6 +58,7 @@ export default async function deleteCollection( }); await removeFolder({ filePath: `archives/${collectionId}` }); + await removeFolder({ filePath: `archives/preview/${collectionId}` }); await removeFromOrders(userId, collectionId); @@ -100,6 +101,7 @@ async function deleteSubCollections(collectionId: number) { }); await removeFolder({ filePath: `archives/${subCollection.id}` }); + await removeFolder({ filePath: `archives/preview/${subCollection.id}` }); } } diff --git a/lib/api/controllers/users/userId/deleteUserById.ts b/lib/api/controllers/users/userId/deleteUserById.ts index 9b65304..a6e6106 100644 --- a/lib/api/controllers/users/userId/deleteUserById.ts +++ b/lib/api/controllers/users/userId/deleteUserById.ts @@ -80,7 +80,7 @@ export default async function deleteUserById( }); // Delete archive folders - removeFolder({ filePath: `archives/${collection.id}` }); + await removeFolder({ filePath: `archives/${collection.id}` }); await removeFolder({ filePath: `archives/preview/${collection.id}`, diff --git a/lib/api/preservationScheme/handleScreenshotAndPdf.ts b/lib/api/preservationScheme/handleScreenshotAndPdf.ts index e6e1bac..bc6922b 100644 --- a/lib/api/preservationScheme/handleScreenshotAndPdf.ts +++ b/lib/api/preservationScheme/handleScreenshotAndPdf.ts @@ -24,10 +24,10 @@ const handleScreenshotAndPdf = async ( if (user.archiveAsScreenshot && !link.image?.startsWith("archive")) { processingPromises.push( - page.screenshot({ fullPage: true, type: "png" }).then((screenshot) => { + page.screenshot({ fullPage: true, type: "jpeg" }).then((screenshot) => { return createFile({ data: screenshot, - filePath: `archives/${linkExists.collectionId}/${link.id}.png`, + filePath: `archives/${linkExists.collectionId}/${link.id}.jpeg`, }); }) ); @@ -60,7 +60,7 @@ const handleScreenshotAndPdf = async ( where: { id: link.id }, data: { image: user.archiveAsScreenshot - ? `archives/${linkExists.collectionId}/${link.id}.png` + ? `archives/${linkExists.collectionId}/${link.id}.jpeg` : undefined, pdf: user.archiveAsPDF ? `archives/${linkExists.collectionId}/${link.id}.pdf`