mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
fix(mobile): do not crash on malformed asset duration (#1921)
* fix(mobile): do not crash on malformed asset duration * add unit test
This commit is contained in:
parent
f52e076cb3
commit
9ac087c59c
3 changed files with 29 additions and 5 deletions
|
|
@ -1,8 +1,13 @@
|
|||
extension DurationExtension on String {
|
||||
Duration toDuration() {
|
||||
final parts =
|
||||
split(':').map((e) => double.parse(e).toInt()).toList(growable: false);
|
||||
return Duration(hours: parts[0], minutes: parts[1], seconds: parts[2]);
|
||||
Duration? toDuration() {
|
||||
try {
|
||||
final parts = split(':')
|
||||
.map((e) => double.parse(e).toInt())
|
||||
.toList(growable: false);
|
||||
return Duration(hours: parts[0], minutes: parts[1], seconds: parts[2]);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
double toDouble() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue