Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Handle errors/exceptions in getThumbnailFileOfPerson

ashilkne61d212ad05c
diff --git a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
index 1af4e69af5..69ba7bfde9 100644
--- a/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
+++ b/mobile/lib/services/machine_learning/face_ml/person/person_service.dart
@@ -487,40 +487,45 @@ class PersonService {
Future<EnteFile?> getThumbnailFileOfPerson(
PersonEntity person,
) async {
- if (person.data.hasAvatar()) {
- final avatarFileID = tryGetFileIdFromFaceId(person.data.avatarFaceID!);
- if (avatarFileID != null) {
- final file = (await FilesDB.instance
- .getFileIDToFileFromIDs([avatarFileID]))[avatarFileID];
- if (file != null) {
- return file;
- } else {
- logger.severe("Avatar File not found for face ${person.data}");
+ try {
+ if (person.data.hasAvatar()) {
+ final avatarFileID = tryGetFileIdFromFaceId(person.data.avatarFaceID!);
+ if (avatarFileID != null) {
+ final file = (await FilesDB.instance
+ .getFileIDToFileFromIDs([avatarFileID]))[avatarFileID];
+ if (file != null) {
+ return file;
+ } else {
+ logger.severe("Avatar File not found for face ${person.data}");
+ }
}
}
- }
- final clustersToFiles =
- await SearchService.instance.getClusterFilesForPersonID(
- person.remoteID,
- );
+ final clustersToFiles =
+ await SearchService.instance.getClusterFilesForPersonID(
+ person.remoteID,
+ );
- EnteFile? resultFile;
- // iterate over all clusters and get the first file
- for (final clusterFiles in clustersToFiles.values) {
- for (final file in clusterFiles) {
- resultFile ??= file;
- if (resultFile.creationTime! < file.creationTime!) {
- resultFile = file;
+ EnteFile? resultFile;
+ // iterate over all clusters and get the first file
+ for (final clusterFiles in clustersToFiles.values) {
+ for (final file in clusterFiles) {
+ resultFile ??= file;
+ if (resultFile.creationTime! < file.creationTime!) {
+ resultFile = file;
+ }
}
}
- }
- if (resultFile == null) {
- logger.warning(
- "Person ${kDebugMode ? person.data.name : person.remoteID} has no files",
- );
+ if (resultFile == null) {
+ logger.warning(
+ "Person ${kDebugMode ? person.data.name : person.remoteID} has no files",
+ );
+ return null;
+ }
+ return resultFile;
+ } catch (e, s) {
+ logger.severe("Error in getThumbnailFileOfPerson", e, s);
return null;
}
- return resultFile;
}
}
diff --git a/mobile/lib/ui/viewer/people/person_selection_action_widgets.dart b/mobile/lib/ui/viewer/people/person_selection_action_widgets.dart
index 128b44c9df..41af361c12 100644
--- a/mobile/lib/ui/viewer/people/person_selection_action_widgets.dart
+++ b/mobile/lib/ui/viewer/people/person_selection_action_widgets.dart
@@ -94,6 +94,7 @@ class _LinkContactToPersonSelectionPageState
_logger.severe(
"Failed to load _personEntitiesWithThumnailFile",
snapshot.error,
+ snapshot.stackTrace,
);
return const Center(child: Icon(Icons.error_outline_rounded));
} else if (!snapshot.hasData || snapshot.data!.isEmpty) {