diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index ff200819f..d0db09a8d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -239,20 +239,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(manga.title, 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) { val wasRunning = downloader.isRunning if (wasRunning) { @@ -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. *