This commit is contained in:
@@ -152,7 +152,7 @@ export const rankVolumes = (volumes: any, scorerConfiguration: any) => {
|
||||
};
|
||||
|
||||
const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
|
||||
new Promise((resolve, reject) => {
|
||||
new Promise((resolve) => {
|
||||
https.get(match.image.small_url, (response: any) => {
|
||||
console.log(rawFileDetails.cover.filePath);
|
||||
const fileName = match.id + "_" + rawFileDetails.name + ".jpg";
|
||||
@@ -166,6 +166,7 @@ const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
|
||||
);
|
||||
const fileStream = response.pipe(file);
|
||||
fileStream.on("finish", async () => {
|
||||
try {
|
||||
// 1. hash of the cover image we have on hand
|
||||
const coverFileName = rawFileDetails.cover.filePath
|
||||
.split("/")
|
||||
@@ -196,9 +197,11 @@ const calculateLevenshteinDistance = async (match: any, rawFileDetails: any) =>
|
||||
} else {
|
||||
match.score -= 2;
|
||||
}
|
||||
}
|
||||
resolve(match);
|
||||
} catch (err) {
|
||||
console.warn(`Image hashing failed for ${fileName}, skipping score adjustment:`, err.message);
|
||||
resolve(match);
|
||||
} else {
|
||||
reject({ error: "Couldn't calculate hashes." });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user