mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 22:39:18 +01:00
Do some download deletion in coroutines instead of completable
This commit is contained in:
parent
eaf1ef831a
commit
3d1250f2f8
@ -16,6 +16,7 @@ import eu.kanade.tachiyomi.source.online.HttpSource
|
|||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.util.lang.combineLatest
|
import eu.kanade.tachiyomi.util.lang.combineLatest
|
||||||
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
import eu.kanade.tachiyomi.util.lang.isNullOrUnsubscribed
|
||||||
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
@ -316,12 +317,9 @@ class LibraryPresenter(
|
|||||||
val mangaToDelete = mangas.distinctBy { it.id }
|
val mangaToDelete = mangas.distinctBy { it.id }
|
||||||
mangaToDelete.forEach { it.favorite = false }
|
mangaToDelete.forEach { it.favorite = false }
|
||||||
|
|
||||||
Observable.fromCallable { db.insertMangas(mangaToDelete).executeAsBlocking() }
|
launchIO {
|
||||||
.onErrorResumeNext { Observable.empty() }
|
db.insertMangas(mangaToDelete).executeAsBlocking()
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe()
|
|
||||||
|
|
||||||
Observable.fromCallable {
|
|
||||||
mangaToDelete.forEach { manga ->
|
mangaToDelete.forEach { manga ->
|
||||||
coverCache.deleteFromCache(manga.thumbnail_url)
|
coverCache.deleteFromCache(manga.thumbnail_url)
|
||||||
if (deleteChapters) {
|
if (deleteChapters) {
|
||||||
@ -332,8 +330,6 @@ class LibraryPresenter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,7 @@ import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
|||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
import eu.kanade.tachiyomi.util.lang.byteSize
|
import eu.kanade.tachiyomi.util.lang.byteSize
|
||||||
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import eu.kanade.tachiyomi.util.lang.takeBytes
|
import eu.kanade.tachiyomi.util.lang.takeBytes
|
||||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||||
import eu.kanade.tachiyomi.util.system.ImageUtil
|
import eu.kanade.tachiyomi.util.system.ImageUtil
|
||||||
@ -651,20 +652,16 @@ class ReaderPresenter(
|
|||||||
val removeAfterReadSlots = preferences.removeAfterReadSlots()
|
val removeAfterReadSlots = preferences.removeAfterReadSlots()
|
||||||
if (removeAfterReadSlots == -1) return
|
if (removeAfterReadSlots == -1) return
|
||||||
|
|
||||||
Completable
|
launchIO {
|
||||||
.fromCallable {
|
// Position of the read chapter
|
||||||
// Position of the read chapter
|
val position = chapterList.indexOf(chapter)
|
||||||
val position = chapterList.indexOf(chapter)
|
|
||||||
|
|
||||||
// Retrieve chapter to delete according to preference
|
// Retrieve chapter to delete according to preference
|
||||||
val chapterToDelete = chapterList.getOrNull(position - removeAfterReadSlots)
|
val chapterToDelete = chapterList.getOrNull(position - removeAfterReadSlots)
|
||||||
if (chapterToDelete != null) {
|
if (chapterToDelete != null) {
|
||||||
downloadManager.enqueueDeleteChapters(listOf(chapterToDelete.chapter), manga)
|
downloadManager.enqueueDeleteChapters(listOf(chapterToDelete.chapter), manga)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.onErrorComplete()
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.subscribe()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -672,10 +669,9 @@ class ReaderPresenter(
|
|||||||
* are ignored.
|
* are ignored.
|
||||||
*/
|
*/
|
||||||
private fun deletePendingChapters() {
|
private fun deletePendingChapters() {
|
||||||
Completable.fromCallable { downloadManager.deletePendingChapters() }
|
launchIO {
|
||||||
.onErrorComplete()
|
downloadManager.deletePendingChapters()
|
||||||
.subscribeOn(Schedulers.io())
|
}
|
||||||
.subscribe()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
Reference in New Issue
Block a user