Don't enqueue bookmarked chapters for deletion (fixes #3691)
(cherry picked from commit 4c8665c9f015cc87c0280fa9495f0748c5490fba)
This commit is contained in:
parent
3b87111f22
commit
2a3eef0610
@ -198,14 +198,10 @@ class DownloadManager(/* SY private */ val context: Context) {
|
|||||||
* @param manga the manga of the chapters.
|
* @param manga the manga of the chapters.
|
||||||
* @param source the source of the chapters.
|
* @param source the source of the chapters.
|
||||||
*/
|
*/
|
||||||
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source) {
|
fun deleteChapters(chapters: List<Chapter>, manga: Manga, source: Source): List<Chapter> {
|
||||||
queue.remove(chapters)
|
val filteredChapters = getChaptersToDelete(chapters)
|
||||||
|
|
||||||
val filteredChapters = if (!preferences.removeBookmarkedChapters()) {
|
queue.remove(filteredChapters)
|
||||||
chapters.filterNot { it.bookmark }
|
|
||||||
} else {
|
|
||||||
chapters
|
|
||||||
}
|
|
||||||
|
|
||||||
val chapterDirs = provider.findChapterDirs(filteredChapters, manga, source)
|
val chapterDirs = provider.findChapterDirs(filteredChapters, manga, source)
|
||||||
chapterDirs.forEach { it.delete() }
|
chapterDirs.forEach { it.delete() }
|
||||||
@ -213,6 +209,8 @@ class DownloadManager(/* SY private */ val context: Context) {
|
|||||||
if (cache.getDownloadCount(manga) == 0) { // Delete manga directory if empty
|
if (cache.getDownloadCount(manga) == 0) { // Delete manga directory if empty
|
||||||
chapterDirs.firstOrNull()?.parentFile?.delete()
|
chapterDirs.firstOrNull()?.parentFile?.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return filteredChapters
|
||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -260,7 +258,7 @@ class DownloadManager(/* SY private */ val context: Context) {
|
|||||||
* @param manga the manga of the chapters.
|
* @param manga the manga of the chapters.
|
||||||
*/
|
*/
|
||||||
fun enqueueDeleteChapters(chapters: List<Chapter>, manga: Manga) {
|
fun enqueueDeleteChapters(chapters: List<Chapter>, manga: Manga) {
|
||||||
pendingDeleter.addChapters(chapters, manga)
|
pendingDeleter.addChapters(getChaptersToDelete(chapters), manga)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,4 +297,12 @@ class DownloadManager(/* SY private */ val context: Context) {
|
|||||||
Timber.e("Could not rename downloaded chapter: %s.", oldNames.joinToString())
|
Timber.e("Could not rename downloaded chapter: %s.", oldNames.joinToString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getChaptersToDelete(chapters: List<Chapter>): List<Chapter> {
|
||||||
|
return if (!preferences.removeBookmarkedChapters()) {
|
||||||
|
chapters.filterNot { it.bookmark }
|
||||||
|
} else {
|
||||||
|
chapters
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -726,16 +726,11 @@ class MangaPresenter(
|
|||||||
* @param chapters the chapters to delete.
|
* @param chapters the chapters to delete.
|
||||||
*/
|
*/
|
||||||
private fun deleteChaptersInternal(chapters: List<ChapterItem>) {
|
private fun deleteChaptersInternal(chapters: List<ChapterItem>) {
|
||||||
val filteredChapters = if (!preferences.removeBookmarkedChapters()) {
|
downloadManager.deleteChapters(chapters, manga, source).forEach {
|
||||||
chapters.filterNot { it.bookmark }
|
if (it is ChapterItem) {
|
||||||
} else {
|
it.status = Download.NOT_DOWNLOADED
|
||||||
chapters
|
it.download = null
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadManager.deleteChapters(filteredChapters, manga, source)
|
|
||||||
filteredChapters.forEach {
|
|
||||||
it.status = Download.NOT_DOWNLOADED
|
|
||||||
it.download = null
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user