Fix/downloader not creating folder or cbz file (#676)

* Create manga download dir in case it's missing for cbz downloads

The directory, in which the cbz file should have been saved in, was never created.

* Correctly copy chapter download to final download location

"renameTo" does not include the content of a directory.
Thus, it just created an empty chapter folder int the final download directory
This commit is contained in:
schroda
2023-09-04 00:10:54 +02:00
committed by GitHub
parent ff6f5d7e89
commit abcbec9c2a
3 changed files with 8 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import suwayomi.tachidesk.manga.impl.download.fileProvider.ChaptersFilesProvider
import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter import suwayomi.tachidesk.manga.impl.download.model.DownloadChapter
import suwayomi.tachidesk.manga.impl.util.getChapterCachePath import suwayomi.tachidesk.manga.impl.util.getChapterCachePath
import suwayomi.tachidesk.manga.impl.util.getChapterCbzPath import suwayomi.tachidesk.manga.impl.util.getChapterCbzPath
import suwayomi.tachidesk.manga.impl.util.getMangaDownloadDir
import java.io.File import java.io.File
import java.io.InputStream import java.io.InputStream
@@ -29,6 +30,7 @@ class ArchiveProvider(mangaId: Int, chapterId: Int) : ChaptersFilesProvider(mang
scope: CoroutineScope, scope: CoroutineScope,
step: suspend (DownloadChapter?, Boolean) -> Unit step: suspend (DownloadChapter?, Boolean) -> Unit
): Boolean { ): Boolean {
val mangaDownloadFolder = File(getMangaDownloadDir(mangaId))
val outputFile = File(getChapterCbzPath(mangaId, chapterId)) val outputFile = File(getChapterCbzPath(mangaId, chapterId))
val chapterCacheFolder = File(getChapterCachePath(mangaId, chapterId)) val chapterCacheFolder = File(getChapterCachePath(mangaId, chapterId))
if (outputFile.exists()) handleExistingCbzFile(outputFile, chapterCacheFolder) if (outputFile.exists()) handleExistingCbzFile(outputFile, chapterCacheFolder)
@@ -36,6 +38,7 @@ class ArchiveProvider(mangaId: Int, chapterId: Int) : ChaptersFilesProvider(mang
super.downloadImpl(download, scope, step) super.downloadImpl(download, scope, step)
withContext(Dispatchers.IO) { withContext(Dispatchers.IO) {
mangaDownloadFolder.mkdirs()
outputFile.createNewFile() outputFile.createNewFile()
} }

View File

@@ -40,9 +40,8 @@ class FolderProvider(mangaId: Int, chapterId: Int) : ChaptersFilesProvider(manga
return false return false
} }
folder.mkdirs()
val cacheChapterDir = getChapterCachePath(mangaId, chapterId) val cacheChapterDir = getChapterCachePath(mangaId, chapterId)
File(cacheChapterDir).renameTo(folder) File(cacheChapterDir).copyRecursively(folder, true)
return true return true
} }

View File

@@ -48,6 +48,10 @@ fun getThumbnailDownloadPath(mangaId: Int): String {
return applicationDirs.thumbnailDownloadsRoot + "/$mangaId" return applicationDirs.thumbnailDownloadsRoot + "/$mangaId"
} }
fun getMangaDownloadDir(mangaId: Int): String {
return applicationDirs.mangaDownloadsRoot + "/" + getMangaDir(mangaId)
}
fun getChapterDownloadPath(mangaId: Int, chapterId: Int): String { fun getChapterDownloadPath(mangaId: Int, chapterId: Int): String {
return applicationDirs.mangaDownloadsRoot + "/" + getChapterDir(mangaId, chapterId) return applicationDirs.mangaDownloadsRoot + "/" + getChapterDir(mangaId, chapterId)
} }