fix cbz import

This commit is contained in:
2024-12-02 20:55:47 +08:00
committed by nyne
parent 1a50b8bc27
commit b8bdda16c6
4 changed files with 81 additions and 73 deletions

View File

@@ -104,14 +104,14 @@ abstract class CBZ {
FilePath.join(LocalManager().path, sanitizeFileName(metaData.title)),
);
dest.createSync();
coverFile.copy(
FilePath.join(dest.path, 'cover.${coverFile.path.split('.').last}'));
coverFile.copyMem(
FilePath.join(dest.path, 'cover.${coverFile.extension}'));
if (metaData.chapters == null) {
for (var i = 0; i < files.length; i++) {
var src = files[i];
var dst = File(
FilePath.join(dest.path, '${i + 1}.${src.path.split('.').last}'));
await src.copy(dst.path);
await src.copyMem(dst.path);
}
} else {
dest.createSync();
@@ -129,7 +129,7 @@ abstract class CBZ {
var src = chapter.value[i];
var dst = File(FilePath.join(
chapterDir.path, '${i + 1}.${src.path.split('.').last}'));
await src.copy(dst.path);
await src.copyMem(dst.path);
}
}
}
@@ -142,10 +142,9 @@ abstract class CBZ {
directory: dest.name,
chapters: cpMap,
downloadedChapters: cpMap?.keys.toList() ?? [],
cover: 'cover.${coverFile.path.split('.').last}',
cover: 'cover.${coverFile.extension}',
createdAt: DateTime.now(),
);
LocalManager().add(comic);
await cache.delete(recursive: true);
return comic;
}
@@ -164,7 +163,7 @@ abstract class CBZ {
var dstName =
'${i.toString().padLeft(width, '0')}.${image.split('.').last}';
var dst = File(FilePath.join(cache.path, dstName));
await src.copy(dst.path);
await src.copyMem(dst.path);
i++;
}
} else {
@@ -192,13 +191,13 @@ abstract class CBZ {
var dstName =
'${i.toString().padLeft(width, '0')}.${image.split('.').last}';
var dst = File(FilePath.join(cache.path, dstName));
await src.copy(dst.path);
await src.copyMem(dst.path);
i++;
}
}
var cover = comic.coverFile;
await cover
.copy(FilePath.join(cache.path, 'cover.${cover.path.split('.').last}'));
.copyMem(FilePath.join(cache.path, 'cover.${cover.path.split('.').last}'));
await File(FilePath.join(cache.path, 'metadata.json')).writeAsString(
jsonEncode(
ComicMetaData(