diff --git a/server/scanner.js b/server/scanner.js index 3c9d30c..b74944c 100755 --- a/server/scanner.js +++ b/server/scanner.js @@ -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);