|
@@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.data.database.models.Chapter
|
|
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
|
|
import eu.kanade.tachiyomi.data.download.model.Download
|
|
|
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
|
|
+import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
|
|
import eu.kanade.tachiyomi.source.Source
|
|
|
import eu.kanade.tachiyomi.source.SourceManager
|
|
|
import eu.kanade.tachiyomi.source.model.Page
|
|
@@ -24,10 +25,8 @@ import uy.kohesive.injekt.injectLazy
|
|
|
*/
|
|
|
class DownloadManager(private val context: Context) {
|
|
|
|
|
|
- /**
|
|
|
- * The sources manager.
|
|
|
- */
|
|
|
- private val sourceManager by injectLazy<SourceManager>()
|
|
|
+ private val sourceManager: SourceManager by injectLazy()
|
|
|
+ private val preferences: PreferencesHelper by injectLazy()
|
|
|
|
|
|
/**
|
|
|
* Downloads provider, used to retrieve the folders where the chapters are or should be stored.
|
|
@@ -201,9 +200,16 @@ class DownloadManager(private val context: Context) {
|
|
|
*/
|
|
|
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source) {
|
|
|
queue.remove(chapters)
|
|
|
- val chapterDirs = provider.findChapterDirs(chapters, manga, source)
|
|
|
+
|
|
|
+ val filteredChapters = if (!preferences.removeBookmarkedChapters()) {
|
|
|
+ chapters.filterNot { it.bookmark }
|
|
|
+ } else {
|
|
|
+ chapters
|
|
|
+ }
|
|
|
+
|
|
|
+ val chapterDirs = provider.findChapterDirs(filteredChapters, manga, source)
|
|
|
chapterDirs.forEach { it.delete() }
|
|
|
- cache.removeChapters(chapters, manga)
|
|
|
+ cache.removeChapters(filteredChapters, manga)
|
|
|
if (cache.getDownloadCount(manga) == 0) { // Delete manga directory if empty
|
|
|
chapterDirs.firstOrNull()?.parentFile?.delete()
|
|
|
}
|