Skip to content

armgit / ente

Public Imported from GitHub
0

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

Match to closest group

laurensprieme26b4796d3cf
diff --git a/mobile/apps/photos/lib/services/machine_learning/similar_images_service.dart b/mobile/apps/photos/lib/services/machine_learning/similar_images_service.dart
index c619f5a8a3..da050a0153 100644
--- a/mobile/apps/photos/lib/services/machine_learning/similar_images_service.dart
+++ b/mobile/apps/photos/lib/services/machine_learning/similar_images_service.dart
@@ -100,7 +100,13 @@ class SimilarImagesService {
needsFullRefresh = true;
}
- // Check condition 1: New files > 20% of total files
+ // Check condition: cache is older than a month
+ if (DateTime.fromMillisecondsSinceEpoch(cachedData.cachedTime)
+ .isBefore(DateTime.now().subtract(const Duration(days: 30)))) {
+ needsFullRefresh = true;
+ }
+
+ // Check condition: new files > 20% of total files
if (!needsFullRefresh) {
final newFileIDs = currentFileIDs.difference(cachedFileIDs);
if (newFileIDs.length > currentFileIDs.length * 0.2) {
@@ -108,7 +114,7 @@ class SimilarImagesService {
}
}
- // Check condition 2: 20+% of grouped files deleted
+ // Check condition: 20+% of grouped files deleted
if (!needsFullRefresh) {
final Set<int> cacheGroupedFileIDs =
await cachedData.getGroupedFileIDs();
@@ -206,12 +212,12 @@ class SimilarImagesService {
final fileDistances = distances[i];
final newFilePersonIDs = fileIDToPersonIDs[newFileID] ?? <String>{};
bool assigned = false;
- for (final group in existingGroups) {
- for (int j = 0; j < similarFileIDs.length; j++) {
- final otherFileID = similarFileIDs[j].toInt();
- if (otherFileID == newFileID) continue;
- final distance = fileDistances[j];
- if (distance > distanceThreshold) break;
+ for (int j = 0; j < similarFileIDs.length; j++) {
+ final otherFileID = similarFileIDs[j].toInt();
+ if (otherFileID == newFileID) continue;
+ final distance = fileDistances[j];
+ if (distance > distanceThreshold) break;
+ for (final group in existingGroups) {
if (group.fileIds.contains(otherFileID)) {
final otherPersonIDs = fileIDToPersonIDs[otherFileID] ?? <String>{};
if (setsAreEqual(newFilePersonIDs, otherPersonIDs)) {