diff --git a/mobile/lib/services/face_ml/face_ml_service.dart b/mobile/lib/services/face_ml/face_ml_service.dart index 05fa7e8b0..0f1664f56 100644 --- a/mobile/lib/services/face_ml/face_ml_service.dart +++ b/mobile/lib/services/face_ml/face_ml_service.dart @@ -425,11 +425,24 @@ class FaceMlService { int fileAnalyzedCount = 0; int fileSkippedCount = 0; final stopwatch = Stopwatch()..start(); - final split = enteFiles.splitMatch((e) => (e.localID ?? '') == ''); + final List filesWithLocalID = []; + final List filesWithoutLocalID = []; + for (final EnteFile enteFile in enteFiles) { + if (_skipAnalysisEnteFile(enteFile, alreadyIndexedFiles)) { + fileSkippedCount++; + continue; + } + if ((enteFile.localID ?? '').isEmpty) { + filesWithoutLocalID.add(enteFile); + } else { + filesWithLocalID.add(enteFile); + } + } + // list of files where files with localID are first final sortedBylocalID = []; - sortedBylocalID.addAll(split.unmatched); - sortedBylocalID.addAll(split.matched); + sortedBylocalID.addAll(filesWithLocalID); + sortedBylocalID.addAll(filesWithoutLocalID); final List> chunks = sortedBylocalID.chunks(kParallelism); outerLoop: for (final chunk in chunks) { @@ -437,9 +450,7 @@ class FaceMlService { final List fileIds = []; // Try to find embeddings on the remote server for (final f in chunk) { - if (!alreadyIndexedFiles.contains(f.uploadedFileID)) { - fileIds.add(f.uploadedFileID!); - } + fileIds.add(f.uploadedFileID!); } try { final res =