Decouple Cache and Download behaviour (#493)

* Separate cache dir from download dir

* Move downloader logic outside of caching/image download logic

* remove unnecessary method duplication

* moved download logic inside download provider

* optimize and handle partial downloads

* made code review changes
This commit is contained in:
akabhirav
2023-02-12 20:26:26 +05:30
committed by GitHub
parent a027d6df1b
commit b10062c73d
9 changed files with 188 additions and 62 deletions

View File

@@ -15,7 +15,6 @@ import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.select
import org.jetbrains.exposed.sql.transactions.transaction
import org.jetbrains.exposed.sql.update
import suwayomi.tachidesk.manga.impl.util.getChapterDir
import suwayomi.tachidesk.manga.impl.util.lang.awaitSingle
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource.getCatalogueSourceOrStub
import suwayomi.tachidesk.manga.impl.util.storage.ImageResponse.getImageResponse
@@ -82,11 +81,13 @@ object Page {
}
}
val chapterDir = getChapterDir(mangaId, chapterId)
File(chapterDir).mkdirs()
val fileName = getPageName(index)
return getImageResponse(chapterDir, fileName, useCache) {
if (chapterEntry[ChapterTable.isDownloaded]) {
return ChapterDownloadHelper.getImage(mangaId, chapterId, index)
}
return getImageResponse(mangaId, chapterId, fileName, useCache) {
source.fetchImage(tachiyomiPage).awaitSingle()
}
}