From 6f848158015f47cad051a8cc63fb49502f033e09 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 2 Feb 2020 18:01:08 -0500 Subject: [PATCH] Filter out tmp directories for download badge --- .../java/eu/kanade/tachiyomi/data/download/DownloadCache.kt | 4 +++- .../java/eu/kanade/tachiyomi/data/download/Downloader.kt | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt index b5c5d8c52..72c3f2a99 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadCache.kt @@ -100,7 +100,9 @@ class DownloadCache( if (sourceDir != null) { val mangaDir = sourceDir.files[provider.getMangaDirName(manga)] if (mangaDir != null) { - return mangaDir.files.size + return mangaDir.files + .filter { !it.endsWith(Downloader.TMP_DIR_SUFFIX) } + .size } } return 0 diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 3da98fc0c..82915d90f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -246,7 +246,7 @@ class Downloader( private fun downloadChapter(download: Download): Observable = Observable.defer { val chapterDirname = provider.getChapterDirName(download.chapter) val mangaDir = provider.getMangaDir(download.manga, download.source) - val tmpDir = mangaDir.createDirectory("${chapterDirname}_tmp") + val tmpDir = mangaDir.createDirectory(chapterDirname + TMP_DIR_SUFFIX) val pageListObservable = if (download.pages == null) { // Pull page list from network and add them to download object @@ -436,4 +436,8 @@ class Downloader( return queue.none { it.status <= Download.DOWNLOADING } } + companion object { + const val TMP_DIR_SUFFIX = "_tmp" + } + }