🔧 Fixes for unsanitized filename not importing

This commit is contained in:
2023-03-14 14:07:43 -04:00
parent 612a6ef344
commit 8b814c0ac5

View File

@@ -87,12 +87,13 @@ export const extractComicInfoXMLFromRar = async (
const archive = new Unrar({ const archive = new Unrar({
path: path.resolve(filePath), path: path.resolve(filePath),
bin: `${UNRAR_BIN_PATH}`, // this will change depending on Docker base OS bin: `${UNRAR_BIN_PATH}`, // this will change depending on Docker base OS
arguments: ["-v"]
}); });
const filesInArchive: [RarFile] = await new Promise( const filesInArchive: [RarFile] = await new Promise(
(resolve, reject) => { (resolve, reject) => {
return archive.list((err, entries) => { return archive.list((err, entries) => {
if (err) { if (err) {
console.log(`DEBUG: ${JSON.stringify(err, null, 2)}` )
reject(err); reject(err);
} }
resolve(entries); resolve(entries);
@@ -161,11 +162,10 @@ export const extractComicInfoXMLFromRar = async (
}); });
const coverFilePromise = new Promise((resolve, reject) => { 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 sharpStream = sharp().resize(275).toFormat("png");
const coverExtractionStream = archive.stream(files[0].name); const coverExtractionStream = archive.stream(files[0].name);
const resizeStream = coverExtractionStream.pipe(sharpStream); const resizeStream = coverExtractionStream.pipe(sharpStream);
resizeStream.toFile( resizeStream.toFile(
`${targetDirectory}/${coverFile}`, `${targetDirectory}/${coverFile}`,
(err, info) => { (err, info) => {
@@ -246,7 +246,8 @@ export const extractComicInfoXMLFromZip = async (
}); });
// Push the first file (cover) to our extraction target // Push the first file (cover) to our extraction target
extractionTargets.push(files[0].name); 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)) { if (!isEmpty(comicInfoXMLFileObject)) {
filesToWriteToDisk.comicInfoXML = comicInfoXMLFileObject[0].name; filesToWriteToDisk.comicInfoXML = comicInfoXMLFileObject[0].name;
extractionTargets.push(filesToWriteToDisk.comicInfoXML); extractionTargets.push(filesToWriteToDisk.comicInfoXML);