Skip to content

armgit / ente

Public Imported from GitHub
0

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

Fix Locker collection diff pagination

Neeraj Guptab24568ea25ae
diff --git a/mobile/apps/locker/lib/services/collections/collections_api_client.dart b/mobile/apps/locker/lib/services/collections/collections_api_client.dart
index abf23f7537..27f0973f47 100644
--- a/mobile/apps/locker/lib/services/collections/collections_api_client.dart
+++ b/mobile/apps/locker/lib/services/collections/collections_api_client.dart
@@ -71,10 +71,14 @@ class CollectionApiClient {
bool hasMore = true;
final List<EnteFile> updatedFiles = [];
final List<EnteFile> deletedFiles = [];
- int latestUpdatedAtTime = 0;
+ int latestUpdatedAtTime = sinceTime;
final collectionKey = CryptoHelper.instance.getCollectionKey(collection);
while (hasMore) {
- final diff = await _getDiff(collection.id, collectionKey, sinceTime);
+ final diff = await _getDiff(
+ collection.id,
+ collectionKey,
+ latestUpdatedAtTime,
+ );
updatedFiles.addAll(diff.updatedFiles);
deletedFiles.addAll(diff.deletedFiles);
latestUpdatedAtTime = max(latestUpdatedAtTime, diff.latestUpdatedAtTime);
diff --git a/mobile/apps/locker/lib/services/collections/collections_service.dart b/mobile/apps/locker/lib/services/collections/collections_service.dart
index 8298f031b5..eaa4f717da 100644
--- a/mobile/apps/locker/lib/services/collections/collections_service.dart
+++ b/mobile/apps/locker/lib/services/collections/collections_service.dart
@@ -1,4 +1,5 @@
import 'dart:async';
+import 'dart:math';
import 'dart:typed_data';
import "package:ente_accounts/services/user_service.dart";
@@ -83,11 +84,6 @@ class CollectionService {
for (final collection in updatedCollections) {
_collectionIDToCollections[collection.id] = collection;
}
- await _db.setSyncTime(updatedCollections.last.updationTime);
- if (shouldCheckFirstSyncCompletion) {
- await _setFirstSyncCompleted();
- }
-
final List<Future<bool>> fileFutures = [];
for (final collection in updatedCollections) {
if (collection.isDeleted) {
@@ -123,6 +119,14 @@ class CollectionService {
}
final fileSyncResults = await Future.wait(fileFutures);
if (fileSyncResults.every((didSync) => didSync)) {
+ await _db.setSyncTime(
+ updatedCollections
+ .map((collection) => collection.updationTime)
+ .reduce(max),
+ );
+ if (shouldCheckFirstSyncCompletion) {
+ await _setFirstSyncCompleted();
+ }
await OfflineFilesService.instance.cleanupInactiveOfflineFiles();
} else {
_logger.warning(