From de4b5b09eff63bdcea7c2b0d44c739d65592de6c Mon Sep 17 00:00:00 2001 From: Fynn Petersen-Frey Date: Tue, 4 Jun 2024 14:14:34 +0200 Subject: [PATCH] fix(mobile): verbose logging of full sync asset loading --- mobile/lib/services/asset.service.dart | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/mobile/lib/services/asset.service.dart b/mobile/lib/services/asset.service.dart index aa156a9586..17f0ebfe62 100644 --- a/mobile/lib/services/asset.service.dart +++ b/mobile/lib/services/asset.service.dart @@ -99,6 +99,8 @@ class AssetService { /// Returns `null` if the server state did not change, else list of assets Future?> _getRemoteAssets(User user, DateTime until) async { const int chunkSize = 10000; + int chunkNumber = 0; + int miniChunkCount = 0; try { final List allAssets = []; DateTime? lastCreationDate; @@ -112,17 +114,35 @@ class AssetService { lastCreationDate: lastCreationDate, userId: user.id, ); + log.fine('Requesting assets older than ($lastCreationDate,$lastId)'); final List? assets = await _apiService.syncApi.getFullSyncForUser(dto); if (assets == null) return null; allAssets.addAll(assets.map(Asset.remote)); if (assets.isEmpty) break; + log.fine( + 'Received ${assets.length} assets ranging from (${assets.first.fileCreatedAt},${assets.first.id}) to (${assets.last.fileCreatedAt},${assets.last.id})', + ); + if (assets.length < 100) { + miniChunkCount++; + if (miniChunkCount > 50) { + log.severe( + 'getRemoteAssets received too many almost empty chunks, stopping. Not all remote assets could be fetched from the server for user ${user.name}.', + ); + break; + } + } lastCreationDate = assets.last.fileCreatedAt; lastId = assets.last.id; + chunkNumber++; } return allAssets; } catch (error, stack) { - log.severe('Error while getting remote assets', error, stack); + log.severe( + 'Error while getting remote assets chunk $chunkNumber', + error, + stack, + ); return null; } }