From 5ec52541bfa06fb6f1e226d689de94e1b2a1ceef Mon Sep 17 00:00:00 2001 From: ashilkn Date: Thu, 6 Mar 2025 01:13:49 +0530 Subject: [PATCH 1/2] [mob][photos] Pass back any exceptions/errors back to main isolate when thrown from a different isolate when using _getLocalIDsAndFilesFromAssets + catch and log in the main isolate so that its reported on sentry --- .../lib/services/local/local_sync_util.dart | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/mobile/lib/services/local/local_sync_util.dart b/mobile/lib/services/local/local_sync_util.dart index c37b37e954..12f273803a 100644 --- a/mobile/lib/services/local/local_sync_util.dart +++ b/mobile/lib/services/local/local_sync_util.dart @@ -34,17 +34,26 @@ Future, List>> getLocalPathAssetsAndFiles( if (assetsInPath.isEmpty) { result = const Tuple2({}, []); } else { - result = await Computer.shared().compute( - _getLocalIDsAndFilesFromAssets, - param: { - "pathEntity": pathEntity, - "fromTime": fromTime, - "alreadySeenLocalIDs": alreadySeenLocalIDs, - "assetList": assetsInPath, - }, - taskName: - "getLocalPathAssetsAndFiles-${pathEntity.name}-count-${assetsInPath.length}", - ); + try { + result = await Computer.shared().compute( + _getLocalIDsAndFilesFromAssets, + param: { + "pathEntity": pathEntity, + "fromTime": fromTime, + "alreadySeenLocalIDs": alreadySeenLocalIDs, + "assetList": assetsInPath, + }, + taskName: + "getLocalPathAssetsAndFiles-${pathEntity.name}-count-${assetsInPath.length}", + ); + } catch (e) { + _logger.severe("_getLocalIDsAndFilesFromAssets failed", e); + _logger.info( + "Failed for pathEntity: ${pathEntity.name}", + ); + result = const Tuple2({}, []); + } + alreadySeenLocalIDs.addAll(result.item1); uniqueFiles.addAll(result.item2); } @@ -299,12 +308,8 @@ Future, List>> _getLocalIDsAndFilesFromAssets( (fromTime / ~1000); if (!alreadySeenLocalIDs.contains(entity.id) && assetCreatedOrUpdatedAfterGivenTime) { - try { - final file = await EnteFile.fromAsset(pathEntity.name, entity); - files.add(file); - } catch (e) { - _logger.severe(e); - } + final file = await EnteFile.fromAsset(pathEntity.name, entity); + files.add(file); } } return Tuple2(localIDs, files); From ff8224529324c90e56806600560024fe33cf9585 Mon Sep 17 00:00:00 2001 From: ashilkn Date: Thu, 6 Mar 2025 15:08:59 +0530 Subject: [PATCH 2/2] [mob][photos] Rethrow --- mobile/lib/services/local/local_sync_util.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/lib/services/local/local_sync_util.dart b/mobile/lib/services/local/local_sync_util.dart index 12f273803a..2be4707a22 100644 --- a/mobile/lib/services/local/local_sync_util.dart +++ b/mobile/lib/services/local/local_sync_util.dart @@ -51,7 +51,7 @@ Future, List>> getLocalPathAssetsAndFiles( _logger.info( "Failed for pathEntity: ${pathEntity.name}", ); - result = const Tuple2({}, []); + rethrow; } alreadySeenLocalIDs.addAll(result.item1);