mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Move deletion actions to the IO thread (#4808)
This commit is contained in:
parent
42a9f911d8
commit
f145fd0dec
1 changed files with 14 additions and 11 deletions
|
@ -12,6 +12,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
|
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
@ -211,16 +212,16 @@ class DownloadManager(private val context: Context) {
|
||||||
*/
|
*/
|
||||||
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source): List<Chapter> {
|
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source): List<Chapter> {
|
||||||
val filteredChapters = getChaptersToDelete(chapters)
|
val filteredChapters = getChaptersToDelete(chapters)
|
||||||
|
launchIO {
|
||||||
|
removeFromDownloadQueue(filteredChapters)
|
||||||
|
|
||||||
removeFromDownloadQueue(filteredChapters)
|
val chapterDirs = provider.findChapterDirs(filteredChapters, manga, source)
|
||||||
|
chapterDirs.forEach { it.delete() }
|
||||||
val chapterDirs = provider.findChapterDirs(filteredChapters, manga, source)
|
cache.removeChapters(filteredChapters, manga)
|
||||||
chapterDirs.forEach { it.delete() }
|
if (cache.getDownloadCount(manga) == 0) { // Delete manga directory if empty
|
||||||
cache.removeChapters(filteredChapters, manga)
|
chapterDirs.firstOrNull()?.parentFile?.delete()
|
||||||
if (cache.getDownloadCount(manga) == 0) { // Delete manga directory if empty
|
}
|
||||||
chapterDirs.firstOrNull()?.parentFile?.delete()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredChapters
|
return filteredChapters
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,9 +250,11 @@ class DownloadManager(private val context: Context) {
|
||||||
* @param source the source of the manga.
|
* @param source the source of the manga.
|
||||||
*/
|
*/
|
||||||
fun deleteManga(manga: Manga, source: Source) {
|
fun deleteManga(manga: Manga, source: Source) {
|
||||||
downloader.queue.remove(manga)
|
launchIO {
|
||||||
provider.findMangaDir(manga, source)?.delete()
|
downloader.queue.remove(manga)
|
||||||
cache.removeManga(manga)
|
provider.findMangaDir(manga, source)?.delete()
|
||||||
|
cache.removeManga(manga)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue