From 8b814c0ac5f60a2a575b92f02eb217635bb1ed31 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Tue, 14 Mar 2023 14:07:43 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fixes=20for=20unsanitized=20file?= =?UTF-8?q?name=20not=20importing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/uncompression.utils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/uncompression.utils.ts b/utils/uncompression.utils.ts index 3a762fa..2efbb4a 100644 --- a/utils/uncompression.utils.ts +++ b/utils/uncompression.utils.ts @@ -87,12 +87,13 @@ export const extractComicInfoXMLFromRar = async ( const archive = new Unrar({ path: path.resolve(filePath), bin: `${UNRAR_BIN_PATH}`, // this will change depending on Docker base OS + arguments: ["-v"] }); - const filesInArchive: [RarFile] = await new Promise( (resolve, reject) => { return archive.list((err, entries) => { if (err) { + console.log(`DEBUG: ${JSON.stringify(err, null, 2)}` ) reject(err); } resolve(entries); @@ -161,11 +162,10 @@ export const extractComicInfoXMLFromRar = async ( }); const coverFilePromise = new Promise((resolve, reject) => { - const coverFile = sanitize(path.basename(files[0].name)); + const coverFile = path.basename(files[0].name); const sharpStream = sharp().resize(275).toFormat("png"); const coverExtractionStream = archive.stream(files[0].name); const resizeStream = coverExtractionStream.pipe(sharpStream); - resizeStream.toFile( `${targetDirectory}/${coverFile}`, (err, info) => { @@ -246,7 +246,8 @@ export const extractComicInfoXMLFromZip = async ( }); // Push the first file (cover) to our extraction target extractionTargets.push(files[0].name); - filesToWriteToDisk.coverFile = sanitize(path.basename(files[0].name)); + filesToWriteToDisk.coverFile = path.basename(files[0].name); + console.log(`sanitized or not, here I am: ${filesToWriteToDisk.coverFile}`); if (!isEmpty(comicInfoXMLFileObject)) { filesToWriteToDisk.comicInfoXML = comicInfoXMLFileObject[0].name; extractionTargets.push(filesToWriteToDisk.comicInfoXML);