From 0647c22956d46b2c249d55680a6df5781014ae29 Mon Sep 17 00:00:00 2001 From: Sergey Katsubo Date: Tue, 4 Nov 2025 06:09:18 +0300 Subject: [PATCH] fix(mobile): handle empty original filename (#23469) * Handle empty original filename * Handle TypeError from photo_manager titleAsync * More compact exception log --- mobile/lib/repositories/asset_media.repository.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mobile/lib/repositories/asset_media.repository.dart b/mobile/lib/repositories/asset_media.repository.dart index e377ff22d6..2e4bdfd32c 100644 --- a/mobile/lib/repositories/asset_media.repository.dart +++ b/mobile/lib/repositories/asset_media.repository.dart @@ -89,9 +89,16 @@ class AssetMediaRepository { return null; } - // titleAsync gets the correct original filename for some assets on iOS - // otherwise using the `entity.title` would return a random GUID - return await entity.titleAsync; + try { + // titleAsync gets the correct original filename for some assets on iOS + // otherwise using the `entity.title` would return a random GUID + final originalFilename = await entity.titleAsync; + // treat empty filename as missing + return originalFilename.isNotEmpty ? originalFilename : null; + } catch (e) { + _log.warning("Failed to get original filename for asset: $id. Error: $e"); + return null; + } } // TODO: make this more efficient