Restrucutre transactions to try and debug HASH conflict issue

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2023-01-12 16:55:35 -08:00
parent be92b7db53
commit fba22f9909

View File

@ -347,6 +347,7 @@ const processBlock = async (items) => {
asset.duplicate = duplicate.photoId;
duplicates.push(asset);
}
return; /* Done processing this asset (DUPLICATE) */
}
@ -381,13 +382,8 @@ const processBlock = async (items) => {
transaction: t
});
});
await Promise.mapSeries(insertHash, async (item) => {
await photoDB.sequelize.query(
"INSERT INTO photohashes (hash,photoId) VALUES(:hash,:id)", {
replacements: item,
transaction: t
});
});
});
await photoDB.sequelize.transaction(async (t) => {
/* Update the DB with the image information */
await Promise.mapSeries(updateAsset, async (item) => {
await photoDB.sequelize.query("UPDATE photos SET " +
@ -398,6 +394,15 @@ const processBlock = async (items) => {
});
});
});
await photoDB.sequelize.transaction(async (t) => {
await Promise.mapSeries(insertHash, async (item) => {
await photoDB.sequelize.query(
"INSERT INTO photohashes (hash,photoId) VALUES(:hash,:id)", {
replacements: item,
transaction: t
});
});
});
} catch (error) {
console.error(error);
process.exit(-1);