Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Better log and handle clusterperson edge case

laurenspriem2d34e9e97cd1
diff --git a/mobile/lib/services/search_service.dart b/mobile/lib/services/search_service.dart
index e15bb33109..e4c84bb71e 100644
--- a/mobile/lib/services/search_service.dart
+++ b/mobile/lib/services/search_service.dart
@@ -902,10 +902,24 @@ class SearchService {
final String clusterName = clusterId;
if (clusterIDToPersonID[clusterId] != null) {
- // This should not happen, means a clusterID is assigned to a personID of a person that no longer exists
- _logger.severe(
- "`getAllFace`: Cluster $clusterId should not have person id ${clusterIDToPersonID[clusterId]}",
- );
+ final String personID = clusterIDToPersonID[clusterId]!;
+ final PersonEntity? p = personIdToPerson[personID];
+ if (p != null) {
+ // This should not be possible since it should be handled in the above loop, logging just in case
+ _logger.severe(
+ "`getAllFace`: Something unexpected happened, Cluster $clusterId should not have person id $personID",
+ );
+ } else {
+ // This should not happen, means a clusterID is still assigned to a personID of a person that no longer exists
+ // Logging the error and deleting the clusterID to personID mapping
+ _logger.severe(
+ "`getAllFace`: Cluster $clusterId should not have person id ${clusterIDToPersonID[clusterId]}, deleting the mapping",
+ );
+ await MLDataDB.instance.removeClusterToPerson(
+ personID: personID,
+ clusterID: clusterId,
+ );
+ }
}
if (files.length < minClusterSize) continue;
facesResult.add(