mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-25 10:28:23 +01:00
Avoid crashing if invalid download and backup location is set
Fixes #8252
This commit is contained in:
parent
824d5e22bc
commit
a8ca7b690f
@ -205,7 +205,7 @@ class AboutScreen : Screen {
|
|||||||
BuildConfig.DEBUG -> {
|
BuildConfig.DEBUG -> {
|
||||||
"Debug ${BuildConfig.COMMIT_SHA}".let {
|
"Debug ${BuildConfig.COMMIT_SHA}".let {
|
||||||
if (withBuildDate) {
|
if (withBuildDate) {
|
||||||
"$it (${getFormattedBuildTime()}"
|
"$it (${getFormattedBuildTime()})"
|
||||||
} else {
|
} else {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
@ -380,8 +380,10 @@ class SettingsBackupScreen : SearchableSettings {
|
|||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
title = stringResource(R.string.pref_backup_directory),
|
title = stringResource(R.string.pref_backup_directory),
|
||||||
subtitle = remember(backupDir) {
|
subtitle = remember(backupDir) {
|
||||||
UniFile.fromUri(context, backupDir.toUri()).filePath!! + "/automatic"
|
(UniFile.fromUri(context, backupDir.toUri())?.filePath)?.let {
|
||||||
},
|
"$it/automatic"
|
||||||
|
}
|
||||||
|
} ?: stringResource(R.string.invalid_location, backupDir),
|
||||||
onClick = {
|
onClick = {
|
||||||
try {
|
try {
|
||||||
pickBackupLocation.launch(null)
|
pickBackupLocation.launch(null)
|
||||||
|
@ -102,8 +102,8 @@ class SettingsDownloadScreen : SearchableSettings {
|
|||||||
pref = currentDirPref,
|
pref = currentDirPref,
|
||||||
title = stringResource(R.string.pref_download_directory),
|
title = stringResource(R.string.pref_download_directory),
|
||||||
subtitle = remember(currentDir) {
|
subtitle = remember(currentDir) {
|
||||||
UniFile.fromUri(context, currentDir.toUri()).filePath!!
|
UniFile.fromUri(context, currentDir.toUri())?.filePath
|
||||||
},
|
} ?: stringResource(R.string.invalid_location, currentDir),
|
||||||
entries = mapOf(
|
entries = mapOf(
|
||||||
defaultDirPair,
|
defaultDirPair,
|
||||||
customDirEntryKey to stringResource(R.string.custom_dir),
|
customDirEntryKey to stringResource(R.string.custom_dir),
|
||||||
|
@ -57,7 +57,7 @@ class DownloadProvider(private val context: Context) {
|
|||||||
.createDirectory(getMangaDirName(mangaTitle))
|
.createDirectory(getMangaDirName(mangaTitle))
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
logcat(LogPriority.ERROR, e) { "Invalid download directory" }
|
logcat(LogPriority.ERROR, e) { "Invalid download directory" }
|
||||||
throw Exception(context.getString(R.string.invalid_download_dir))
|
throw Exception(context.getString(R.string.invalid_location, downloadsDir))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,6 +422,7 @@
|
|||||||
<string name="pref_remove_bookmarked_chapters">Allow deleting bookmarked chapters</string>
|
<string name="pref_remove_bookmarked_chapters">Allow deleting bookmarked chapters</string>
|
||||||
<string name="pref_remove_exclude_categories">Excluded categories</string>
|
<string name="pref_remove_exclude_categories">Excluded categories</string>
|
||||||
<string name="custom_dir">Custom location</string>
|
<string name="custom_dir">Custom location</string>
|
||||||
|
<string name="invalid_location">Invalid location: %s</string>
|
||||||
<string name="disabled">Disabled</string>
|
<string name="disabled">Disabled</string>
|
||||||
<string name="last_read_chapter">Last read chapter</string>
|
<string name="last_read_chapter">Last read chapter</string>
|
||||||
<string name="second_to_last">Second to last read chapter</string>
|
<string name="second_to_last">Second to last read chapter</string>
|
||||||
@ -658,7 +659,6 @@
|
|||||||
<string name="error_saving_cover">Error saving cover</string>
|
<string name="error_saving_cover">Error saving cover</string>
|
||||||
<string name="error_sharing_cover">Error sharing cover</string>
|
<string name="error_sharing_cover">Error sharing cover</string>
|
||||||
<string name="confirm_delete_chapters">Are you sure you want to delete the selected chapters?</string>
|
<string name="confirm_delete_chapters">Are you sure you want to delete the selected chapters?</string>
|
||||||
<string name="invalid_download_dir">Invalid download location</string>
|
|
||||||
<string name="chapter_settings">Chapter settings</string>
|
<string name="chapter_settings">Chapter settings</string>
|
||||||
<string name="confirm_set_chapter_settings">Are you sure you want to save these settings as default?</string>
|
<string name="confirm_set_chapter_settings">Are you sure you want to save these settings as default?</string>
|
||||||
<string name="also_set_chapter_settings_for_library">Also apply to all manga in my library</string>
|
<string name="also_set_chapter_settings_for_library">Also apply to all manga in my library</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user