fix(mobile): handle empty original filename (#23469)

* Handle empty original filename

* Handle TypeError from photo_manager titleAsync

* More compact exception log
pull/23581/head
Sergey Katsubo 2025-11-04 06:09:18 +03:00 committed by GitHub
parent b8087b4fa2
commit 0647c22956
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -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