Fix EXIF error when converting from JSON

This commit is contained in:
Ming Ming 2021-04-15 06:55:47 +08:00
parent 400abd33e4
commit 12421aa1d8
2 changed files with 17 additions and 8 deletions

View file

@ -106,6 +106,14 @@ class Album {
File albumFile, File albumFile,
}) { }) {
// there's only one version right now // there's only one version right now
if (version < 2) {
return Album(
lastUpdated: lastUpdated,
name: name,
items: [],
albumFile: albumFile,
);
} else {
return Album( return Album(
lastUpdated: lastUpdated, lastUpdated: lastUpdated,
name: name, name: name,
@ -113,6 +121,7 @@ class Album {
albumFile: albumFile, albumFile: albumFile,
); );
} }
}
factory Album.fromJson(Map<String, dynamic> json) { factory Album.fromJson(Map<String, dynamic> json) {
return Album.versioned( return Album.versioned(
@ -191,7 +200,7 @@ class Album {
final File albumFile; final File albumFile;
/// versioning of this class, use to upgrade old persisted album /// versioning of this class, use to upgrade old persisted album
static const version = 1; static const version = 2;
} }
class AlbumRepo { class AlbumRepo {

View file

@ -44,7 +44,7 @@ class Exif {
if (e is Map) { if (e is Map) {
return Rational.fromJson(e.cast<String, dynamic>()); return Rational.fromJson(e.cast<String, dynamic>());
} else { } else {
return value; return e;
} }
}).toList(); }).toList();
} else { } else {