🔧 Added error handling for temp folder in CV matching

This commit is contained in:
2025-02-20 12:38:13 -05:00
parent ab08613689
commit 42f2f522b8

View File

@@ -31,7 +31,7 @@ SOFTWARE.
* Initial: 2021/07/29 Rishi Ghan
*/
import { createWriteStream } from "fs";
import { createWriteStream, existsSync, mkdirSync } from "fs";
import path from "path";
import https from "https";
import stringSimilarity from "string-similarity";
@@ -151,6 +151,10 @@ const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
https.get(match.image.small_url, (response: any) => {
console.log(rawFileDetails.cover.filePath);
const fileName = match.id + "_" + rawFileDetails.name + ".jpg";
// Ensure the `temporary` directory exists
if (!existsSync("temporary")) {
mkdirSync("temporary", { recursive: true });
}
const file = createWriteStream(
`${process.env.USERDATA_DIRECTORY}/temporary/${fileName}`
);