π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Fix incorrect file deletion when widget unmounts during thumbnail loading
ashilkn70eb68b13cc0
diff --git a/mobile/apps/photos/lib/core/exceptions.dart b/mobile/apps/photos/lib/core/exceptions.dartnew file mode 100644index 0000000000..e4bcdee7eb--- /dev/null+++ b/mobile/apps/photos/lib/core/exceptions.dart@@ -0,0 +1,13 @@+/// Common runtime exceptions that can occur during normal app operation.+/// These are recoverable conditions that should be caught and handled.++class WidgetUnmountedException implements Exception {+ final String? message;++ WidgetUnmountedException([this.message]);++ @override+ String toString() => message != null+ ? 'WidgetUnmountedException: $message'+ : 'WidgetUnmountedException';+}\ No newline at end of filediff --git a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dartindex cbc707d6d4..9b1a9125f4 100644--- a/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/file/thumbnail_widget.dart@@ -7,6 +7,7 @@ import 'package:logging/logging.dart';import 'package:photos/core/cache/thumbnail_in_memory_cache.dart';import 'package:photos/core/constants.dart';import 'package:photos/core/errors.dart';+import 'package:photos/core/exceptions.dart';import 'package:photos/core/event_bus.dart';import 'package:photos/db/files_db.dart';import 'package:photos/db/trash_db.dart';@@ -307,8 +308,13 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {thumbnailSmallSize,);}).catchError((e) {- _logger.warning("Could not load thumbnail from disk: ", e);_errorLoadingLocalThumbnail = true;+ if (e is WidgetUnmountedException) {+ // Widget was unmounted - this is expected behavior+ _logger.fine("Thumbnail loading cancelled: widget unmounted");+ } else {+ _logger.warning("Could not load thumbnail from disk: ", e);+ }});}@@ -326,7 +332,7 @@ class _ThumbnailWidgetState extends State<ThumbnailWidget> {}//Do not retry if the widget is not mountedif (!mounted) {- return null;+ throw WidgetUnmountedException("Thumbnail loading cancelled: widget unmounted");}retryAttempts++;