Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Decrypt remote embeddings in computer

laurenspriem3e79c8cf28ed
diff --git a/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dart b/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dart
index eafbc6323d..bb1c9f999b 100644
--- a/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dart
+++ b/mobile/lib/services/machine_learning/file_ml/remote_fileml_service.dart
@@ -1,6 +1,7 @@
import "dart:async";
import "dart:convert";
+import "package:computer/computer.dart";
import "package:logging/logging.dart";
import "package:photos/core/network/network.dart";
import "package:photos/db/files_db.dart";
@@ -16,6 +17,8 @@ import "package:shared_preferences/shared_preferences.dart";
class RemoteFileMLService {
RemoteFileMLService._privateConstructor();
+ static final Computer _computer = Computer.shared();
+
static final RemoteFileMLService instance =
RemoteFileMLService._privateConstructor();
@@ -107,15 +110,17 @@ class RemoteFileMLService {
final input = EmbeddingsDecoderInput(embedding, fileKey);
inputs.add(input);
}
- // todo: use compute or isolate
- return decryptFileMLComputer(
- {
+ return _computer.compute<Map<String, dynamic>, Map<int, FileMl>>(
+ _decryptFileMLComputer,
+ param: {
"inputs": inputs,
},
);
}
- Future<Map<int, FileMl>> decryptFileMLComputer(
+}
+
+Future<Map<int, FileMl>> _decryptFileMLComputer(
Map<String, dynamic> args,
) async {
final result = <int, FileMl>{};
@@ -134,5 +139,4 @@ class RemoteFileMLService {
result[input.embedding.fileID] = decodedEmbedding;
}
return result;
- }
-}
+ }
\ No newline at end of file