Skip to content

armgit / ente

Public Imported from GitHub
0

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

Better update in memory cache

laurenspriem2c50b84e304a
diff --git a/mobile/lib/db/ml/db.dart b/mobile/lib/db/ml/db.dart
index 322bb90303..a1d2a6ccf1 100644
--- a/mobile/lib/db/ml/db.dart
+++ b/mobile/lib/db/ml/db.dart
@@ -1286,6 +1286,8 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
];
}
+ /// WARNING: Better to use the similarly named [putFaceIdCachedForPersonOrCluster]
+ /// method from face_thumbnail_cache instead!
Future<void> putFaceIdCachedForPersonOrCluster(
String personOrClusterId,
String faceID,
diff --git a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
index 025cbc8bf1..e7ca73a4bb 100644
--- a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
@@ -443,10 +443,7 @@ class PersonService {
data: person.data.copyWith(avatarFaceId: face.faceID),
);
await updatePerson(updatedPerson);
- await faceMLDataDB.putFaceIdCachedForPersonOrCluster(
- p.remoteID,
- face.faceID,
- );
+ await putFaceIdCachedForPersonOrCluster(p.remoteID, face.faceID);
return updatedPerson;
}
diff --git a/mobile/lib/utils/face/face_box_crop.dart b/mobile/lib/utils/face/face_box_crop.dart
index 74fe92e22a..37542dd1f8 100644
--- a/mobile/lib/utils/face/face_box_crop.dart
+++ b/mobile/lib/utils/face/face_box_crop.dart
@@ -65,6 +65,17 @@ Future<String?> checkUsedFaceIDForPersonOrClusterId(
return faceIDFromDB;
}
+Future<void> putFaceIdCachedForPersonOrCluster(
+ String personOrClusterID,
+ String faceID,
+) async {
+ await MLDataDB.instance.putFaceIdCachedForPersonOrCluster(
+ personOrClusterID,
+ faceID,
+ );
+ _personOrClusterIdToCachedFaceID.put(personOrClusterID, faceID);
+}
+
Future<void> _putCachedCropForFaceID(
String faceID,
Uint8List data, [
@@ -72,11 +83,7 @@ Future<void> _putCachedCropForFaceID(
]) async {
_faceCropCache.put(faceID, data);
if (personOrClusterID != null) {
- await MLDataDB.instance.putFaceIdCachedForPersonOrCluster(
- personOrClusterID,
- faceID,
- );
- _personOrClusterIdToCachedFaceID.put(personOrClusterID, faceID);
+ await putFaceIdCachedForPersonOrCluster(personOrClusterID, faceID);
}
}