Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Store local empty clip result on errors

laurenspriem47128ab52daa
diff --git a/mobile/lib/db/embeddings_db.dart b/mobile/lib/db/embeddings_db.dart
index b5a6111f45..4da5c056a5 100644
--- a/mobile/lib/db/embeddings_db.dart
+++ b/mobile/lib/db/embeddings_db.dart
@@ -123,7 +123,9 @@ class EmbeddingsDB {
List<Embedding> _convertToEmbeddings(List<Map<String, dynamic>> results) {
final List<Embedding> embeddings = [];
for (final result in results) {
- embeddings.add(_getEmbeddingFromRow(result));
+ final embedding = _getEmbeddingFromRow(result);
+ if (embedding.isEmpty) continue;
+ embeddings.add(embedding);
}
return embeddings;
}
diff --git a/mobile/lib/models/embedding.dart b/mobile/lib/models/embedding.dart
index c8f742caa9..91ac9a0213 100644
--- a/mobile/lib/models/embedding.dart
+++ b/mobile/lib/models/embedding.dart
@@ -6,6 +6,8 @@ class Embedding {
final List<double> embedding;
int? updationTime;
+ bool get isEmpty => embedding.isEmpty;
+
Embedding({
required this.fileID,
required this.model,
@@ -13,6 +15,14 @@ class Embedding {
this.updationTime,
});
+ factory Embedding.empty(int fileID, Model model) {
+ return Embedding(
+ fileID: fileID,
+ model: model,
+ embedding: <double>[],
+ );
+ }
+
static List<double> decodeEmbedding(String embedding) {
return List<double>.from(jsonDecode(embedding) as List);
}
diff --git a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart
index 8c4418f2a8..bfe8d9cec7 100644
--- a/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart
+++ b/mobile/lib/services/machine_learning/semantic_search/semantic_search_service.dart
@@ -3,6 +3,7 @@ import "dart:collection";
import "dart:math" show min;
import "package:computer/computer.dart";
+import "package:flutter/services.dart";
import "package:logging/logging.dart";
import "package:photos/core/cache/lru_map.dart";
import "package:photos/core/configuration.dart";
@@ -333,6 +334,21 @@ class SemanticSearchService {
file,
embedding,
);
+ } on FormatException catch (e, _) {
+ _logger.severe(
+ "Could not get embedding for $file because FormatException occured, storing empty result locally",
+ e,
+ );
+ final embedding = Embedding.empty(file.uploadedFileID!, _currentModel);
+ await EmbeddingsDB.instance.put(embedding);
+ } on PlatformException catch (e, s) {
+ _logger.severe(
+ "Could not get thumbnail for $file due to PlatformException related to thumbnails, storing empty result locally",
+ e,
+ s,
+ );
+ final embedding = Embedding.empty(file.uploadedFileID!, _currentModel);
+ await EmbeddingsDB.instance.put(embedding);
} catch (e, s) {
_logger.severe(e, s);
}