mirror of
https://github.com/kodjodevf/mangayomi.git
synced 2026-04-20 10:52:05 +00:00
Reduce I/O operations
getMangaChapterDirectory() now accepts an optional mangaMainDirectory to avoid calling getMangaMainDirectory() and thus getDirectory() twice in places where both methods are called successively.
This commit is contained in:
parent
46526c6b6b
commit
2698db6085
5 changed files with 25 additions and 7 deletions
|
|
@ -1472,7 +1472,10 @@ class _LibraryScreenState extends ConsumerState<LibraryScreen>
|
|||
final mangaDir = await storageProvider
|
||||
.getMangaMainDirectory(chapter);
|
||||
final path = await storageProvider
|
||||
.getMangaChapterDirectory(chapter);
|
||||
.getMangaChapterDirectory(
|
||||
chapter,
|
||||
mangaMainDirectory: mangaDir,
|
||||
);
|
||||
|
||||
try {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,10 @@ class ChapterPageDownload extends ConsumerWidget {
|
|||
void _sendFile() async {
|
||||
final storageProvider = StorageProvider();
|
||||
final mangaDir = await storageProvider.getMangaMainDirectory(chapter);
|
||||
final path = await storageProvider.getMangaChapterDirectory(chapter);
|
||||
final path = await storageProvider.getMangaChapterDirectory(
|
||||
chapter,
|
||||
mangaMainDirectory: mangaDir,
|
||||
);
|
||||
|
||||
List<XFile> files = [];
|
||||
|
||||
|
|
@ -57,7 +60,10 @@ class ChapterPageDownload extends ConsumerWidget {
|
|||
void _deleteFile(int downloadId) async {
|
||||
final storageProvider = StorageProvider();
|
||||
final mangaDir = await storageProvider.getMangaMainDirectory(chapter);
|
||||
final path = await storageProvider.getMangaChapterDirectory(chapter);
|
||||
final path = await storageProvider.getMangaChapterDirectory(
|
||||
chapter,
|
||||
mangaMainDirectory: mangaDir,
|
||||
);
|
||||
|
||||
try {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,10 @@ Future<void> downloadChapter(
|
|||
final chapterName = chapter.name!.replaceForbiddenCharacters(' ');
|
||||
final itemType = chapter.manga.value!.itemType;
|
||||
final chapterDirectory =
|
||||
(await storageProvider.getMangaChapterDirectory(chapter))!;
|
||||
(await storageProvider.getMangaChapterDirectory(
|
||||
chapter,
|
||||
mangaMainDirectory: mangaMainDirectory,
|
||||
))!;
|
||||
await Directory(chapterDirectory.path).create(recursive: true);
|
||||
Map<String, String> videoHeader = {};
|
||||
Map<String, String> htmlHeader = {
|
||||
|
|
|
|||
|
|
@ -103,8 +103,11 @@ class StorageProvider {
|
|||
);
|
||||
}
|
||||
|
||||
Future<Directory?> getMangaChapterDirectory(Chapter chapter) async {
|
||||
final basedir = await getMangaMainDirectory(chapter);
|
||||
Future<Directory?> getMangaChapterDirectory(
|
||||
Chapter chapter, {
|
||||
Directory? mangaMainDirectory,
|
||||
}) async {
|
||||
final basedir = mangaMainDirectory ?? await getMangaMainDirectory(chapter);
|
||||
String scanlator =
|
||||
chapter.scanlator?.isNotEmpty ?? false
|
||||
? "${chapter.scanlator!.replaceForbiddenCharacters('_')}_"
|
||||
|
|
|
|||
|
|
@ -50,8 +50,11 @@ Future<GetChapterPagesModel> getChapterPages(
|
|||
.firstOrNull;
|
||||
final incognitoMode = ref.watch(incognitoModeStateProvider);
|
||||
final storageProvider = StorageProvider();
|
||||
path = await storageProvider.getMangaChapterDirectory(chapter);
|
||||
final mangaDirectory = await storageProvider.getMangaMainDirectory(chapter);
|
||||
path = await storageProvider.getMangaChapterDirectory(
|
||||
chapter,
|
||||
mangaMainDirectory: mangaDirectory,
|
||||
);
|
||||
|
||||
List<Uint8List?> archiveImages = [];
|
||||
final isLocalArchive = (chapter.archivePath ?? '').isNotEmpty;
|
||||
|
|
|
|||
Loading…
Reference in a new issue