mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Merge pull request #4737 from Bnyro/master
fix: crash when downloaded filename too long
This commit is contained in:
commit
f08b0cda7c
@ -162,11 +162,17 @@ class DownloadDialog : DialogFragment() {
|
||||
restorePreviousSelections(binding, videoStreams, audioStreams, subtitles)
|
||||
|
||||
onDownloadConfirm = onDownloadConfirm@{
|
||||
if (binding.fileName.text.toString().isEmpty()) {
|
||||
val fileName = binding.fileName.text.toString()
|
||||
if (fileName.isBlank()) {
|
||||
Toast.makeText(context, R.string.invalid_filename, Toast.LENGTH_SHORT).show()
|
||||
return@onDownloadConfirm
|
||||
}
|
||||
|
||||
if (fileName.length > MAX_FILE_NAME_LENGTH - 20) { // reserve 20 chars for quality and extension
|
||||
Toast.makeText(context, R.string.filename_too_long, Toast.LENGTH_SHORT).show()
|
||||
return@onDownloadConfirm
|
||||
}
|
||||
|
||||
val videoPosition = binding.videoSpinner.selectedItemPosition - 1
|
||||
val audioPosition = binding.audioSpinner.selectedItemPosition - 1
|
||||
val subtitlePosition = binding.subtitleSpinner.selectedItemPosition - 1
|
||||
@ -269,6 +275,11 @@ class DownloadDialog : DialogFragment() {
|
||||
}
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Max file name length at Android systems
|
||||
*/
|
||||
private const val MAX_FILE_NAME_LENGTH = 255
|
||||
|
||||
private const val VIDEO_DOWNLOAD_QUALITY = "video_download_quality"
|
||||
private const val VIDEO_DOWNLOAD_FORMAT = "video_download_format"
|
||||
private const val AUDIO_DOWNLOAD_QUALITY = "audio_download_quality"
|
||||
|
@ -472,6 +472,7 @@
|
||||
<string name="segment_type">Segment type</string>
|
||||
<string name="sb_invalid_segment">Invalid segment start or end</string>
|
||||
<string name="contribute_to_sponsorblock">Contribute to SponsorBlock</string>
|
||||
<string name="filename_too_long">Filename too long!</string>
|
||||
|
||||
<!-- Notification channel strings -->
|
||||
<string name="download_channel_name">Download Service</string>
|
||||
|
Loading…
Reference in New Issue
Block a user