[mob][photos] Don't process large files on mobile
This commit is contained in:
@@ -7,3 +7,4 @@ const minimumClusterSize = 2;
|
||||
|
||||
const embeddingFetchLimit = 200;
|
||||
final fileDownloadMlLimit = Platform.isIOS ? 5 : 10;
|
||||
const maxFileDownloadSize = 100000000;
|
||||
|
||||
@@ -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)],
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user