Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Don't process large files on mobile

laurensprieme1ce35306956
diff --git a/mobile/lib/models/ml/ml_versions.dart b/mobile/lib/models/ml/ml_versions.dart
index 2d382209dc..35d089178a 100644
--- a/mobile/lib/models/ml/ml_versions.dart
+++ b/mobile/lib/models/ml/ml_versions.dart
@@ -7,3 +7,4 @@ const minimumClusterSize = 2;
const embeddingFetchLimit = 200;
final fileDownloadMlLimit = Platform.isIOS ? 5 : 10;
+const maxFileDownloadSize = 100000000;
diff --git a/mobile/lib/services/machine_learning/ml_service.dart b/mobile/lib/services/machine_learning/ml_service.dart
index b048301ad1..616e2bb2a1 100644
--- a/mobile/lib/services/machine_learning/ml_service.dart
+++ b/mobile/lib/services/machine_learning/ml_service.dart
@@ -488,6 +488,14 @@ class MLService {
);
acceptedIssue = true;
}
+ if (errorString.contains('FileSizeTooLargeForMobileIndexing')) {
+ _logger.severe(
+ '$errorString with ID ${instruction.file.uploadedFileID}, storing empty results so indexing does not get stuck',
+ e,
+ s,
+ );
+ acceptedIssue = true;
+ }
if (acceptedIssue) {
await MLDataDB.instance.bulkInsertFaces(
[Face.empty(instruction.file.uploadedFileID!, error: true)],
diff --git a/mobile/lib/utils/ml_util.dart b/mobile/lib/utils/ml_util.dart
index e07740acba..01ddd353a9 100644
--- a/mobile/lib/utils/ml_util.dart
+++ b/mobile/lib/utils/ml_util.dart
@@ -153,7 +153,8 @@ Future<List<FileMLInstruction>> getFilesForMlIndexing() async {
}
Stream<List<FileMLInstruction>> fetchEmbeddingsAndInstructions(
- int yieldSize,) async* {
+ int yieldSize,
+) async* {
final List<FileMLInstruction> filesToIndex = await getFilesForMlIndexing();
final List<List<FileMLInstruction>> chunks =
filesToIndex.chunks(embeddingFetchLimit);
@@ -312,6 +313,12 @@ Future<String> getImagePathForML(EnteFile enteFile) async {
throw ThumbnailRetrievalException(e.toString(), s);
}
} else {
+ // Don't process the file if it's too large (more than 100MB)
+ if (enteFile.fileSize != null && enteFile.fileSize! > maxFileDownloadSize) {
+ throw Exception(
+ "FileSizeTooLargeForMobileIndexing: size is ${enteFile.fileSize}",
+ );
+ }
try {
file = await getFile(enteFile, isOrigin: true);
} catch (e, s) {