Perf: Avoid redundant reading and decrypting all collections (#1133)

This commit is contained in:
Neeraj Gupta 2023-05-23 15:27:34 +05:30 committed by GitHub
commit 9a93ed4de8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,7 +92,7 @@ class CollectionsService {
// sync method fetches just sync the collections, not the individual files
// within the collection.
Future<List<Collection>> sync() async {
Future<void> sync() async {
_logger.info("Syncing collections");
final EnteWatch watch = EnteWatch("syncCollection")..start();
final lastCollectionUpdationTime =
@ -101,7 +101,10 @@ class CollectionsService {
// Might not have synced the collection fully
final fetchedCollections =
await _fetchCollections(lastCollectionUpdationTime);
watch.log("remote fetch");
watch.log("remote fetch collections ${fetchedCollections.length}");
if (fetchedCollections.isEmpty) {
return;
}
final updatedCollections = <Collection>[];
int maxUpdationTime = lastCollectionUpdationTime;
final ownerID = _config.getUserID();
@ -152,7 +155,6 @@ class CollectionsService {
),
);
}
return collections;
}
void clearCache() {