Skip to content

armgit / ente

Public Imported from GitHub
0

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

Delete stale pet rows before re-indexing a file

Amrithesh Kakkoth Enteecb9288df580
diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
index 56fc8b3cee..75144c44f3 100644
--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
@@ -630,9 +630,11 @@ class MLService {
}
}
- // Pet results locally
+ // Pet results locally β€” delete stale rows before writing so
+ // re-indexing with fewer detections doesn't leave old data behind.
final rustPets = result.petFaces != null || result.petBodies != null;
if (rustPets) {
+ await mlDataDB.deletePetDataForFiles([result.fileId]);
if (result.petFaces != null && result.petFaces!.isNotEmpty) {
final dbPetFaces = result.petFaces!.map((pf) {
return DBPetFace(
@@ -719,6 +721,7 @@ class MLService {
);
}
if (instruction.shouldRunPets) {
+ await mlDataDB.deletePetDataForFiles([instruction.fileKey]);
await mlDataDB.bulkInsertPetFaces(
[DBPetFace.empty(instruction.fileKey, error: true)],
);