fix(server): proper asset sync (#10019)

* fix(server,mobile): proper asset sync

* fix CI issues

* only use id instead of createdAt+id

* remove createdAt index

* fix typo

* cleanup createdAt usage

---------

Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
This commit is contained in:
Fynn Petersen-Frey 2024-06-09 21:19:28 +02:00 committed by GitHub
parent 69795a3763
commit 972c66d467
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 38 additions and 121 deletions

View file

@ -101,7 +101,6 @@ class AssetService {
const int chunkSize = 10000;
try {
final List<Asset> allAssets = [];
DateTime? lastCreationDate;
String? lastId;
// will break on error or once all assets are loaded
while (true) {
@ -109,15 +108,17 @@ class AssetService {
limit: chunkSize,
updatedUntil: until,
lastId: lastId,
lastCreationDate: lastCreationDate,
userId: user.id,
);
log.fine("Requesting $chunkSize assets from $lastId");
final List<AssetResponseDto>? assets =
await _apiService.syncApi.getFullSyncForUser(dto);
if (assets == null) return null;
log.fine(
"Received ${assets.length} assets from ${assets.firstOrNull?.id} to ${assets.lastOrNull?.id}",
);
allAssets.addAll(assets.map(Asset.remote));
if (assets.isEmpty) break;
lastCreationDate = assets.last.fileCreatedAt;
if (assets.length != chunkSize) break;
lastId = assets.last.id;
}
return allAssets;