Delete empty source folder when deleting all downloads for a manga
It previously only attempted this after deleting a list of chapters, so it wasn't applicable when deleting from Library or after unfavoriting an entry. Closes #8594 (cherry picked from commit 5c37347cecc99582752ee500171e8480008c836e) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt
This commit is contained in:
parent
c07ccf7943
commit
aefdc2adbe
@ -242,20 +242,33 @@ class DownloadManager(
|
||||
|
||||
// Delete manga directory if empty
|
||||
if (mangaDir?.listFiles()?.isEmpty() == true) {
|
||||
mangaDir.delete()
|
||||
cache.removeManga(manga)
|
||||
|
||||
// Delete source directory if empty
|
||||
val sourceDir = provider.findSourceDir(source)
|
||||
if (sourceDir?.listFiles()?.isEmpty() == true) {
|
||||
sourceDir.delete()
|
||||
cache.removeSource(source)
|
||||
}
|
||||
deleteManga(manga, source)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the directory of a downloaded manga.
|
||||
*
|
||||
* @param manga the manga to delete.
|
||||
* @param source the source of the manga.
|
||||
*/
|
||||
fun deleteManga(manga: Manga, source: Source) {
|
||||
launchIO {
|
||||
downloader.queue.remove(manga)
|
||||
provider.findMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source)?.delete()
|
||||
cache.removeManga(manga)
|
||||
|
||||
// Delete source directory if empty
|
||||
val sourceDir = provider.findSourceDir(source)
|
||||
if (sourceDir?.listFiles()?.isEmpty() == true) {
|
||||
sourceDir.delete()
|
||||
cache.removeSource(source)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeFromDownloadQueue(chapters: List<Chapter>) {
|
||||
val wasRunning = downloader.isRunning
|
||||
if (wasRunning) {
|
||||
@ -327,19 +340,6 @@ class DownloadManager(
|
||||
// SY <--
|
||||
|
||||
/**
|
||||
* Deletes the directory of a downloaded manga.
|
||||
*
|
||||
* @param manga the manga to delete.
|
||||
* @param source the source of the manga.
|
||||
*/
|
||||
fun deleteManga(manga: Manga, source: Source) {
|
||||
launchIO {
|
||||
downloader.queue.remove(manga)
|
||||
provider.findMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source)?.delete()
|
||||
cache.removeManga(manga)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a list of chapters to be deleted later.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user