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
This commit is contained in:
arkon 2022-11-22 09:25:00 -05:00
parent ef3a6c80a7
commit 5c37347cec

View File

@ -239,7 +239,22 @@ class DownloadManager(
// Delete manga directory if empty // Delete manga directory if empty
if (mangaDir?.listFiles()?.isEmpty() == true) { if (mangaDir?.listFiles()?.isEmpty() == true) {
mangaDir.delete() 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(manga.title, source)?.delete()
cache.removeManga(manga) cache.removeManga(manga)
// Delete source directory if empty // Delete source directory if empty
@ -250,8 +265,6 @@ class DownloadManager(
} }
} }
} }
}
}
private fun removeFromDownloadQueue(chapters: List<Chapter>) { private fun removeFromDownloadQueue(chapters: List<Chapter>) {
val wasRunning = downloader.isRunning val wasRunning = downloader.isRunning
@ -271,20 +284,6 @@ class DownloadManager(
} }
} }
/**
* 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(manga.title, source)?.delete()
cache.removeManga(manga)
}
}
/** /**
* Adds a list of chapters to be deleted later. * Adds a list of chapters to be deleted later.
* *