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

This commit is contained in:
laurenspriem
2024-08-28 11:08:18 +02:00
parent 61c1847d75
commit e1ce353069
3 changed files with 17 additions and 1 deletions

View File

@@ -7,3 +7,4 @@ const minimumClusterSize = 2;
const embeddingFetchLimit = 200;
final fileDownloadMlLimit = Platform.isIOS ? 5 : 10;
const maxFileDownloadSize = 100000000;

View File

@@ -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)],

View File

@@ -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) {