Provide more human readable error when downloading to invalid directory (#2462)

This commit is contained in:
arkon 2020-01-09 08:39:40 -05:00 committed by Carlos
parent d62f0de862
commit 13a2d3dfdd
3 changed files with 10 additions and 4 deletions

View File

@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.download
import android.content.Context
import android.net.Uri
import com.hippo.unifile.UniFile
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.database.models.Chapter
import eu.kanade.tachiyomi.data.database.models.Manga
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -46,9 +47,13 @@ class DownloadProvider(private val context: Context) {
* @param source the source of the manga.
*/
internal fun getMangaDir(manga: Manga, source: Source): UniFile {
try {
return downloadsDir
.createDirectory(getSourceDirName(source))
.createDirectory(getMangaDirName(manga))
} catch (e: NullPointerException) {
throw Exception(context.getString(R.string.invalid_download_dir))
}
}
/**

View File

@ -102,7 +102,7 @@ class Downloader(
pending.forEach { if (it.status != Download.QUEUE) it.status = Download.QUEUE }
downloadsRelay.call(pending)
return !pending.isEmpty()
return pending.isNotEmpty()
}
/**

View File

@ -394,6 +394,7 @@
<string name="download_all">All</string>
<string name="download_unread">Unread</string>
<string name="confirm_delete_chapters">Are you sure you want to delete selected chapters?</string>
<string name="invalid_download_dir">Invalid download directory</string>
<!-- Tracking Screen -->
<string name="manga_tracking_tab">Tracking</string>