Improve handling of downloads for chapters with same metadata and optionally for OSes that don't support Unicode in filename (#2305)
Co-authored-by: jkim <jhskim@hotmail.com> Co-authored-by: fatotak <111342761+fatotak@users.noreply.github.com> Co-authored-by: MajorTanya <39014446+MajorTanya@users.noreply.github.com> Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
@@ -484,6 +484,7 @@ class LibraryScreenModel(
|
||||
downloadManager.isChapterDownloaded(
|
||||
chapter.name,
|
||||
chapter.scanlator,
|
||||
chapter.url,
|
||||
manga.title,
|
||||
manga.source,
|
||||
)
|
||||
|
||||
@@ -527,7 +527,13 @@ class MangaScreenModel(
|
||||
val downloaded = if (isLocal) {
|
||||
true
|
||||
} else {
|
||||
downloadManager.isChapterDownloaded(chapter.name, chapter.scanlator, manga.title, manga.source)
|
||||
downloadManager.isChapterDownloaded(
|
||||
chapter.name,
|
||||
chapter.scanlator,
|
||||
chapter.url,
|
||||
manga.title,
|
||||
manga.source,
|
||||
)
|
||||
}
|
||||
val downloadState = when {
|
||||
activeDownload != null -> activeDownload.status
|
||||
|
||||
@@ -38,7 +38,6 @@ import eu.kanade.tachiyomi.util.chapter.filterDownloaded
|
||||
import eu.kanade.tachiyomi.util.chapter.removeDuplicates
|
||||
import eu.kanade.tachiyomi.util.editCover
|
||||
import eu.kanade.tachiyomi.util.lang.byteSize
|
||||
import eu.kanade.tachiyomi.util.lang.takeBytes
|
||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||
import eu.kanade.tachiyomi.util.storage.cacheImageDir
|
||||
import kotlinx.coroutines.CancellationException
|
||||
@@ -175,6 +174,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
!downloadManager.isChapterDownloaded(
|
||||
it.name,
|
||||
it.scanlator,
|
||||
it.url,
|
||||
manga.title,
|
||||
manga.source,
|
||||
)
|
||||
@@ -184,6 +184,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
downloadManager.isChapterDownloaded(
|
||||
it.name,
|
||||
it.scanlator,
|
||||
it.url,
|
||||
manga.title,
|
||||
manga.source,
|
||||
)
|
||||
@@ -397,6 +398,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
val isDownloaded = downloadManager.isChapterDownloaded(
|
||||
dbChapter.name,
|
||||
dbChapter.scanlator,
|
||||
dbChapter.url,
|
||||
manga.title,
|
||||
manga.source,
|
||||
skipCache = true,
|
||||
@@ -473,6 +475,7 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
val isNextChapterDownloaded = downloadManager.isChapterDownloaded(
|
||||
nextChapter.name,
|
||||
nextChapter.scanlator,
|
||||
nextChapter.url,
|
||||
manga.title,
|
||||
manga.source,
|
||||
)
|
||||
@@ -757,7 +760,8 @@ class ReaderViewModel @JvmOverloads constructor(
|
||||
val chapter = page.chapter.chapter
|
||||
val filenameSuffix = " - ${page.number}"
|
||||
return DiskUtil.buildValidFilename(
|
||||
"${manga.title} - ${chapter.name}".takeBytes(DiskUtil.MAX_FILE_NAME_BYTES - filenameSuffix.byteSize()),
|
||||
"${manga.title} - ${chapter.name}",
|
||||
DiskUtil.MAX_FILE_NAME_BYTES - filenameSuffix.byteSize(),
|
||||
) + filenameSuffix
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ class ChapterLoader(
|
||||
val isDownloaded = downloadManager.isChapterDownloaded(
|
||||
dbChapter.name,
|
||||
dbChapter.scanlator,
|
||||
dbChapter.url,
|
||||
manga.title,
|
||||
manga.source,
|
||||
skipCache = true,
|
||||
|
||||
@@ -33,7 +33,13 @@ internal class DownloadPageLoader(
|
||||
|
||||
override suspend fun getPages(): List<ReaderPage> {
|
||||
val dbChapter = chapter.chapter
|
||||
val chapterPath = downloadProvider.findChapterDir(dbChapter.name, dbChapter.scanlator, manga.title, source)
|
||||
val chapterPath = downloadProvider.findChapterDir(
|
||||
dbChapter.name,
|
||||
dbChapter.scanlator,
|
||||
dbChapter.url,
|
||||
manga.title,
|
||||
source,
|
||||
)
|
||||
return if (chapterPath?.isFile == true) {
|
||||
getPagesFromArchive(chapterPath)
|
||||
} else {
|
||||
|
||||
@@ -37,6 +37,7 @@ class ReaderTransitionView @JvmOverloads constructor(context: Context, attrs: At
|
||||
downloadManager.isChapterDownloaded(
|
||||
chapterName = goingToChapter.name,
|
||||
chapterScanlator = goingToChapter.scanlator,
|
||||
chapterUrl = goingToChapter.url,
|
||||
mangaTitle = manga.title,
|
||||
sourceId = manga.source,
|
||||
skipCache = true,
|
||||
|
||||
@@ -107,6 +107,7 @@ class UpdatesScreenModel(
|
||||
val downloaded = downloadManager.isChapterDownloaded(
|
||||
update.chapterName,
|
||||
update.scanlator,
|
||||
update.chapterUrl,
|
||||
update.mangaTitle,
|
||||
update.sourceId,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user