mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +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:
committed by
GitHub
parent
f52e076cb3
commit
9ac087c59c
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user