Start downloader after a library update. It should help with some catalogue issues

This commit is contained in:
inorichi 2017-12-02 17:29:05 +01:00
parent 182bf5f2bd
commit 34a40b0131
3 changed files with 11 additions and 5 deletions

View file

@ -85,9 +85,10 @@ class DownloadManager(context: Context) {
* *
* @param manga the manga of the chapters. * @param manga the manga of the chapters.
* @param chapters the list of chapters to enqueue. * @param chapters the list of chapters to enqueue.
* @param autoStart whether to start the downloader after enqueing the chapters.
*/ */
fun downloadChapters(manga: Manga, chapters: List<Chapter>) { fun downloadChapters(manga: Manga, chapters: List<Chapter>, autoStart: Boolean = true) {
downloader.queueChapters(manga, chapters) downloader.queueChapters(manga, chapters, autoStart)
} }
/** /**

View file

@ -219,8 +219,9 @@ class Downloader(private val context: Context,
* *
* @param manga the manga of the chapters to download. * @param manga the manga of the chapters to download.
* @param chapters the list of chapters to download. * @param chapters the list of chapters to download.
* @param autoStart whether to start the downloader after enqueing the chapters.
*/ */
fun queueChapters(manga: Manga, chapters: List<Chapter>) = launchUI { fun queueChapters(manga: Manga, chapters: List<Chapter>, autoStart: Boolean) = launchUI {
val source = sourceManager.get(manga.source) as? HttpSource ?: return@launchUI val source = sourceManager.get(manga.source) as? HttpSource ?: return@launchUI
// Called in background thread, the operation can be slow with SAF. // Called in background thread, the operation can be slow with SAF.
@ -261,7 +262,9 @@ class Downloader(private val context: Context,
} }
// Start downloader if needed // Start downloader if needed
DownloadService.start(this@Downloader.context) if (autoStart) {
DownloadService.start(this@Downloader.context)
}
} }
} }

View file

@ -333,7 +333,9 @@ class LibraryUpdateService(
val dbChapters = chapters.map { val dbChapters = chapters.map {
mangaChapters.find { mangaChapter -> mangaChapter.url == it.url }!! mangaChapters.find { mangaChapter -> mangaChapter.url == it.url }!!
} }
downloadManager.downloadChapters(manga, dbChapters) // We don't want to start downloading while the library is updating, because websites
// may don't like it and they could ban the user.
downloadManager.downloadChapters(manga, dbChapters, false)
} }
/** /**