Fixed crash caused by empty chapter list.

This commit is contained in:
2025-02-23 20:24:43 +08:00
parent 587c5d8040
commit fd19f6bf7d
2 changed files with 4 additions and 2 deletions

View File

@@ -336,8 +336,10 @@ class ComicChapters {
}
if (chapters.isNotEmpty) {
return ComicChapters(chapters);
} else {
} else if (groupedChapters.isNotEmpty) {
return ComicChapters.grouped(groupedChapters);
} else {
throw ArgumentError("Empty chapter list");
}
}

View File

@@ -177,7 +177,7 @@ abstract class CBZ {
tags: metaData.tags,
comicType: ComicType.local,
directory: dest.name,
chapters: ComicChapters.fromJson(cpMap),
chapters: ComicChapters.fromJsonOrNull(cpMap),
downloadedChapters: cpMap?.keys.toList() ?? [],
cover: 'cover.${coverFile.extension}',
createdAt: DateTime.now(),