mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-01-11 22:40:36 +00:00
Fix indexing and path for downloaded chapter images and update padding logic
This commit is contained in:
parent
0960a5b80a
commit
0f430f80d9
4 changed files with 11 additions and 9 deletions
|
|
@ -281,7 +281,7 @@ Future<void> downloadChapter(
|
|||
|
||||
if (itemType == ItemType.manga) {
|
||||
final file = File(
|
||||
p.join(chapterDirectory.path, "${padIndex(index + 1)}.jpg"),
|
||||
p.join(chapterDirectory.path, "${padIndex(index)}.jpg"),
|
||||
);
|
||||
if (!file.existsSync()) {
|
||||
pages.add(
|
||||
|
|
@ -290,7 +290,7 @@ Future<void> downloadChapter(
|
|||
headers: pageHeaders,
|
||||
fileName: p.join(
|
||||
chapterDirectory.path,
|
||||
"${padIndex(index + 1)}.jpg",
|
||||
"${padIndex(index)}.jpg",
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:mangayomi/eval/lib.dart';
|
||||
import 'package:mangayomi/eval/javascript/http.dart';
|
||||
import 'package:mangayomi/main.dart';
|
||||
|
|
@ -93,10 +94,7 @@ Future<GetChapterPagesModel> getChapterPages(
|
|||
} else {
|
||||
for (var i = 0; i < pageUrls.length; i++) {
|
||||
archiveImages.add(null);
|
||||
if (await File(
|
||||
"${path!.path}"
|
||||
"${padIndex(i + 1)}.jpg",
|
||||
).exists()) {
|
||||
if (await File(p.join(path!.path, '${padIndex(i)}.jpg')).exists()) {
|
||||
isLocaleList.add(true);
|
||||
} else {
|
||||
isLocaleList.add(false);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import 'package:mangayomi/utils/headers.dart';
|
|||
import 'package:mangayomi/utils/reg_exp_matcher.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
|
||||
extension LetExtension<T> on T {
|
||||
R let<R>(R Function(T) block) {
|
||||
|
|
@ -49,7 +50,7 @@ extension UChapDataPreloadExtensions on UChapDataPreload {
|
|||
imageBytes = archiveImage;
|
||||
} else if (isLocale!) {
|
||||
imageBytes = File(
|
||||
'${directory!.path}${padIndex(index! + 1)}.jpg',
|
||||
p.join(directory!.path, "${padIndex(index!)}.jpg"),
|
||||
).readAsBytesSync();
|
||||
} else {
|
||||
File? cachedImage;
|
||||
|
|
@ -86,7 +87,10 @@ extension UChapDataPreloadExtensions on UChapDataPreload {
|
|||
? ExtendedMemoryImageProvider(archiveImage)
|
||||
: ExtendedFileImageProvider(
|
||||
File(
|
||||
'${data.directory!.path}${padIndex(data.index! + 1)}.jpg',
|
||||
p.join(
|
||||
data.directory!.path,
|
||||
"${padIndex(data.index!)}.jpg",
|
||||
),
|
||||
),
|
||||
)
|
||||
: CustomExtendedNetworkImageProvider(
|
||||
|
|
|
|||
|
|
@ -38,5 +38,5 @@ String regCustomMatcher(String input, String source, int group) {
|
|||
}
|
||||
|
||||
String padIndex(int index) {
|
||||
return index.toString().padLeft(3, "0");
|
||||
return (index + 1).toString().padLeft(3, "0");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue