π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Bound refresh indexing to 100 files while continuing embedding sync
laurenspriem8ea14479d0d6
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dartindex 5637836155..d38a5f451e 100644--- a/mobile/apps/photos/lib/main.dart+++ b/mobile/apps/photos/lib/main.dart@@ -407,6 +407,7 @@ Future<void> _runMinimally(final disposition = await MLService.instance.runAllML(force: false,allowImageIndexing: BgTaskUtils.allowsImageIndexing(taskId),+ maxFilesToIndex: BgTaskUtils.isRefreshTask(taskId) ? 100 : null,control: mlRunControl,lockWait: mlLockWait,);diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dartindex 05feb84134..dea6834969 100644--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart@@ -343,6 +343,7 @@ class MLService {Future<MlRunDisposition> runAllML({bool force = false,bool allowImageIndexing = true,+ int? maxFilesToIndex,MlRunControl? control,Duration? lockWait,}) async {@@ -395,6 +396,7 @@ class MLService {mode: mode,force: force,allowImageIndexing: allowImageIndexing,+ maxFilesToIndex: maxFilesToIndex,control: runControl,);},@@ -436,6 +438,7 @@ class MLService {required MLMode mode,required bool force,required bool allowImageIndexing,+ required int? maxFilesToIndex,required MlRunControl control,}) async {assert(MlProcessLock.instance.isBusy, "ml funnel must be held");@@ -472,6 +475,7 @@ class MLService {mode: mode,control: control,allowImageIndexing: allowImageIndexing,+ maxFilesToIndex: maxFilesToIndex,);}if (control.stopRequested) {@@ -590,6 +594,7 @@ class MLService {required MLMode mode,required MlRunControl control,bool allowImageIndexing = true,+ int? maxFilesToIndex,}) async {assert(MlProcessLock.instance.isBusy, "ml funnel must be held");if (control.stopRequested) {@@ -610,6 +615,7 @@ class MLService {fetchEmbeddingsAndInstructions(fileDownloadMlLimit, mode: mode);int fileAnalyzedCount = 0;+ int fileAttemptCount = 0;final Stopwatch stopwatch = Stopwatch()..start();bool stopRun = false;@@ -640,7 +646,10 @@ class MLService {}}final futures = <Future<bool>>[];- for (final instruction in chunk) {+ final instructions = maxFilesToIndex == null+ ? chunk+ : chunk.take(maxFilesToIndex - fileAttemptCount);+ for (final instruction in instructions) {if (control.stopRequested) {_logRunStopped(control, "between indexing instructions");stopRun = true;@@ -648,6 +657,7 @@ class MLService {}futures.add(_processImage(instruction));}+ fileAttemptCount += futures.length;// Drain: work that was already started must complete (and commit)// before this run can exit and release the process lock.final awaitedFutures = await Future.wait(futures);@@ -656,6 +666,9 @@ class MLService {(previousValue, element) => previousValue + (element ? 1 : 0),);fileAnalyzedCount += sumFutures;+ if (fileAttemptCount == maxFilesToIndex) {+ allowImageIndexing = false;+ }if (stopRun) {break;}diff --git a/mobile/apps/photos/lib/utils/bg_task_utils.dart b/mobile/apps/photos/lib/utils/bg_task_utils.dartindex fa1255e45a..d30b5f40d5 100644--- a/mobile/apps/photos/lib/utils/bg_task_utils.dart+++ b/mobile/apps/photos/lib/utils/bg_task_utils.dart@@ -139,9 +139,14 @@ class BgTaskUtils {"io.ente.photos.androidBackgroundProcessing";static bool allowsImageIndexing(String taskName) =>+ isRefreshTask(taskName) ||taskName == iOSBackgroundProcessingTask ||taskName == androidBackgroundProcessingTask;+ static bool isRefreshTask(String taskName) =>+ taskName == iOSBackgroundAppRefreshTask ||+ taskName == androidPeriodicTask;+static Duration taskStartupElapsedFor(String taskName,SharedPreferences prefs,