Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Recover face previews after local retrieval failures

laurenspriem20cfb800da4e
diff --git a/mobile/apps/photos/changes/face-preview-source-recovery.md b/mobile/apps/photos/changes/face-preview-source-recovery.md
new file mode 100644
index 0000000000..82f76d4430
--- /dev/null
+++ b/mobile/apps/photos/changes/face-preview-source-recovery.md
@@ -0,0 +1 @@
+- Fixed face previews failing to load when local photo files become unavailable.
diff --git a/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart b/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart
index 0c1df56277..6b64f3f786 100644
--- a/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart
+++ b/mobile/apps/photos/lib/utils/face/face_thumbnail_cache.dart
@@ -388,7 +388,9 @@ Future<Map<String, Uint8List>?> _getFaceCrops(
late String? imagePath;
if (useFullFile && file.fileType != FileType.video) {
File? ioFile = await getFile(file);
- if (ioFile == null && file.isUploaded && !file.isRemoteOnlyFile) {
+ if (file.isUploaded &&
+ !file.isRemoteOnlyFile &&
+ (ioFile == null || !await ioFile.exists())) {
ioFile = await getFile(EnteFile.from(file)..localID = null);
}
if (ioFile == null) {
@@ -397,7 +399,19 @@ Future<Map<String, Uint8List>?> _getFaceCrops(
}
imagePath = ioFile.path;
} else {
- var thumbnail = await getThumbnailForUploadedFile(file);
+ File? thumbnail;
+ try {
+ thumbnail = await getThumbnailForUploadedFile(file);
+ } catch (e, s) {
+ if (!file.isUploaded || file.isRemoteOnlyFile) {
+ rethrow;
+ }
+ _logger.warning(
+ "Failed to get local thumbnail for face crop generation",
+ e,
+ s,
+ );
+ }
if (thumbnail == null && file.isUploaded && !file.isRemoteOnlyFile) {
thumbnail = await getThumbnailForUploadedFile(
EnteFile.from(file)..localID = null,