fix: case for empty headers
This commit is contained in:
parent
4d28ae2e3e
commit
2f30bdb6a8
2 changed files with 18 additions and 16 deletions
|
@ -53,10 +53,10 @@ class DownloadsManager(private val context: Context) {
|
|||
saveDownloads()
|
||||
}
|
||||
|
||||
fun removeDownload(downloadedType: DownloadedType, onFinished: () -> Unit) {
|
||||
fun removeDownload(downloadedType: DownloadedType, toast: Boolean = true, onFinished: () -> Unit) {
|
||||
downloadsList.remove(downloadedType)
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
removeDirectory(downloadedType)
|
||||
removeDirectory(downloadedType, toast)
|
||||
withContext(Dispatchers.Main) {
|
||||
onFinished()
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ class DownloadsManager(private val context: Context) {
|
|||
}
|
||||
}
|
||||
|
||||
private fun removeDirectory(downloadedType: DownloadedType) {
|
||||
private fun removeDirectory(downloadedType: DownloadedType, toast: Boolean) {
|
||||
val baseDirectory = getBaseDirectory(context, downloadedType.type)
|
||||
val directory =
|
||||
baseDirectory?.findFolder(downloadedType.title)?.findFolder(downloadedType.chapter)
|
||||
|
@ -222,8 +222,7 @@ class DownloadsManager(private val context: Context) {
|
|||
if (directory?.exists() == true) {
|
||||
val deleted = directory.deleteRecursively(context, false)
|
||||
if (deleted) {
|
||||
snackString("Successfully deleted")
|
||||
|
||||
if (toast) snackString("Successfully deleted")
|
||||
} else {
|
||||
snackString("Failed to delete directory")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue