Provide more human readable error when downloading to invalid directory (#2462)
This commit is contained in:
parent
d62f0de862
commit
13a2d3dfdd
3 changed files with 10 additions and 4 deletions
|
@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.data.download
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import com.hippo.unifile.UniFile
|
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.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
|
@ -46,9 +47,13 @@ class DownloadProvider(private val context: Context) {
|
||||||
* @param source the source of the manga.
|
* @param source the source of the manga.
|
||||||
*/
|
*/
|
||||||
internal fun getMangaDir(manga: Manga, source: Source): UniFile {
|
internal fun getMangaDir(manga: Manga, source: Source): UniFile {
|
||||||
return downloadsDir
|
try {
|
||||||
.createDirectory(getSourceDirName(source))
|
return downloadsDir
|
||||||
.createDirectory(getMangaDirName(manga))
|
.createDirectory(getSourceDirName(source))
|
||||||
|
.createDirectory(getMangaDirName(manga))
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
throw Exception(context.getString(R.string.invalid_download_dir))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -102,7 +102,7 @@ class Downloader(
|
||||||
pending.forEach { if (it.status != Download.QUEUE) it.status = Download.QUEUE }
|
pending.forEach { if (it.status != Download.QUEUE) it.status = Download.QUEUE }
|
||||||
|
|
||||||
downloadsRelay.call(pending)
|
downloadsRelay.call(pending)
|
||||||
return !pending.isEmpty()
|
return pending.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -394,6 +394,7 @@
|
||||||
<string name="download_all">All</string>
|
<string name="download_all">All</string>
|
||||||
<string name="download_unread">Unread</string>
|
<string name="download_unread">Unread</string>
|
||||||
<string name="confirm_delete_chapters">Are you sure you want to delete selected chapters?</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 -->
|
<!-- Tracking Screen -->
|
||||||
<string name="manga_tracking_tab">Tracking</string>
|
<string name="manga_tracking_tab">Tracking</string>
|
||||||
|
|
Reference in a new issue