Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Fix fetch for shared file index when local indexing is disabled

Neeraj Gupta0a6121e1fa3b
diff --git a/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart b/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart
index 5a9b21add7..ab3ece3d50 100644
--- a/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart
+++ b/mobile/lib/ui/settings/ml/machine_learning_settings_page.dart
@@ -486,7 +486,7 @@ class MLStatusWidgetState extends State<MLStatusWidget> {
trailingWidget: Text(
total < 1
? 'NA'
- : indexedFiles * 100 ~/ total > 100
+ : pendingFiles == 0
? '100%'
: '${(indexedFiles * 100.0 / total * 1.0).toStringAsFixed(2)}%',
style: Theme.of(context).textTheme.bodySmall,
diff --git a/mobile/lib/utils/ml_util.dart b/mobile/lib/utils/ml_util.dart
index 1f32068136..cb49af7757 100644
--- a/mobile/lib/utils/ml_util.dart
+++ b/mobile/lib/utils/ml_util.dart
@@ -76,6 +76,11 @@ Future<IndexStatus> getIndexStatus() async {
}
}
+// _lastFetchTimeForOthersIndexed indicates the last time we tried to
+// fetch embeddings for files that are owned by others. This is only used
+// when local indexing is disabled.
+int _lastFetchTimeForOthersIndexed = 0;
+
/// Return a list of file instructions for files that should be indexed for ML
Future<List<FileMLInstruction>> getFilesForMlIndexing() async {
_logger.info('getFilesForMlIndexing called');
@@ -160,6 +165,18 @@ Future<List<FileMLInstruction>> getFilesForMlIndexing() async {
"Getting list of ${sortedBylocalID.length} files to index for ML took ${DateTime.now().difference(time).inMilliseconds} ms",
);
if (!localSettings.isMLLocalIndexingEnabled) {
+ final time = DateTime.now().millisecondsSinceEpoch;
+ if ((time - _lastFetchTimeForOthersIndexed) > 1000 * 60 * 60 * 24) {
+ final filesOwnedByOthers = [];
+ for (final instruction in splitResult.unmatched) {
+ if (instruction.file.isUploaded && !instruction.file.isOwner) {
+ filesOwnedByOthers.add(instruction);
+ }
+ }
+ _logger.info(
+ 'Chececking index for ${filesOwnedByOthers.length} owned by others');
+ return [...splitResult.matched, ...filesOwnedByOthers];
+ }
return splitResult.matched;
}
return [...splitResult.matched, ...splitResult.unmatched];