diff --git a/server/routes/index.js b/server/routes/index.js index 15709e4..a5b19a3 100755 --- a/server/routes/index.js +++ b/server/routes/index.js @@ -48,7 +48,8 @@ router.get("/*", function(req, res, next) { } let source; - switch (req.url) { + console.log(JSON.stringify(parts, null, 2)); + switch (parts.pathname) { case "/": source = "frontend/index.html"; break; diff --git a/server/routes/photos.js b/server/routes/photos.js index 687892e..51832cc 100755 --- a/server/routes/photos.js +++ b/server/routes/photos.js @@ -366,8 +366,9 @@ router.get("/status/:token", function(req, res) { /** * 1. Look if there are duplicates. * 2. Update all other duplicates to be duplicates of the first image that remains - * 3. If no duplicates, DELETE the entry from photohashes - * 4. If there are duplicates, update the HASH entry to point to the first image that remains + * 3. If no duplicates, DELETE the entry from referencing tables: + * photohashes, faces + * 4. If there are duplicates, update the HASH (and any FACE) entry to point to the first image that remains * 5. Delete the entry from photos * 6. Delete the scaled, thumb, and original from disk */ @@ -387,7 +388,7 @@ const deletePhoto = function(photo) { duplicates.forEach(function(duplicate) { needsUpdate.push(duplicate.id); }); - + if (!needsUpdate.length) { return first; } @@ -407,11 +408,19 @@ const deletePhoto = function(photo) { }).then(function(first) { if (!first) { console.log("Deleting "+ photo.id + " from photohash."); - // 3. If no duplicates, DELETE the entry from photohashes + // 3. If no duplicates, DELETE the entry from photohashes and faces return photoDB.sequelize.query( "DELETE FROM photohashes WHERE photoId=:id", { replacements: photo, transaction: transaction + }).then(() => { + console.log("Deleting "+ photo.id + " from faces."); + // 3. If no duplicates, DELETE the entry from photohashes + return photoDB.sequelize.query( + "DELETE FROM faces WHERE photoId=:id", { + replacements: photo, + transaction: transaction + }); }); } console.log("Updating photohash for " + photo.id + " to point to " + first.id); @@ -423,6 +432,16 @@ const deletePhoto = function(photo) { photo: photo.id }, transaction: transaction + }).then(() => { + console.log("Updating faces for " + photo.id + " to point to " + first.id); + return photoDB.sequelize.query( + "UPDATE faces SET photoId=:first WHERE photoId=:photo", { + replacements: { + first: first.id, + photo: photo.id + }, + transaction: transaction + }); }); }).then(function() { console.log("Deleting " + photo.path + photo.filename + " from DB."); diff --git a/src/App.js b/src/App.js index 01f0bcb..0bc665f 100755 --- a/src/App.js +++ b/src/App.js @@ -582,12 +582,13 @@ function createIdentityBlock(identity, nolimit) { break; } const target = identity.relatedFaces[i]; - const facePhoto = createFace(target.faceId, target.photoId), - distance = document.createElement("div"); - - distance.classList.add("distance"); - distance.textContent = target.distance.toFixed(2); - facePhoto.appendChild(distance); + const facePhoto = createFace(target.faceId, target.photoId); + if (target.distance > 0.01) { + const distance = document.createElement("div"); + distance.classList.add("distance"); + distance.textContent = target.distance.toFixed(2); + facePhoto.appendChild(distance); + } div.appendChild(facePhoto); }