Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Fix database issue

laurenspriema2023bd4579e
diff --git a/mobile/lib/face/db.dart b/mobile/lib/face/db.dart
index 05450b9687..594f9aa4fe 100644
--- a/mobile/lib/face/db.dart
+++ b/mobile/lib/face/db.dart
@@ -81,7 +81,7 @@ class FaceMLDataDB {
INSERT INTO $facesTable (
$fileIDColumn, $faceIDColumn, $faceDetectionColumn, $faceEmbeddingBlob, $faceScore, $faceBlur, $isSideways, $imageHeight, $imageWidth, $mlVersionColumn
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
- ON CONFLICT($faceIDColumn, $mlVersionColumn) DO NOTHING
+ ON CONFLICT($fileIDColumn, $faceIDColumn) DO UPDATE SET $faceIDColumn = excluded.$faceIDColumn, $faceDetectionColumn = excluded.$faceDetectionColumn, $faceEmbeddingBlob = excluded.$faceEmbeddingBlob, $faceScore = excluded.$faceScore, $faceBlur = excluded.$faceBlur, $isSideways = excluded.$isSideways, $imageHeight = excluded.$imageHeight, $imageWidth = excluded.$imageWidth, $mlVersionColumn = excluded.$mlVersionColumn
''';
final parameterSets = batch.map((face) {
final map = mapRemoteToFaceDB(face);
diff --git a/mobile/lib/face/db_fields.dart b/mobile/lib/face/db_fields.dart
index c7d0c703c4..b9fc723125 100644
--- a/mobile/lib/face/db_fields.dart
+++ b/mobile/lib/face/db_fields.dart
@@ -16,7 +16,7 @@ const mlVersionColumn = 'ml_version';
const createFacesTable = '''CREATE TABLE IF NOT EXISTS $facesTable (
$fileIDColumn INTEGER NOT NULL,
- $faceIDColumn TEXT NOT NULL,
+ $faceIDColumn TEXT NOT NULL UNIQUE,
$faceDetectionColumn TEXT NOT NULL,
$faceEmbeddingBlob BLOB NOT NULL,
$faceScore REAL NOT NULL,
diff --git a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart
index cbc5aab3a4..b0aa9218f2 100644
--- a/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/face_ml_service.dart
@@ -870,7 +870,7 @@ class FaceMlService {
stopwatch.stop();
_logger.info(
"Finished Analyze image (${result.faces.length} faces) with uploadedFileID ${enteFile.uploadedFileID}, in "
- "${stopwatch.elapsedMilliseconds} ms",
+ "${stopwatch.elapsedMilliseconds} ms (including time waiting for inference engine availability)",
);
return result;