Fallback chapter name if it ends up as blank (#9220)
* change the directory's name for a download when the chapter's name is only composed of numbers or is blank * maj in case the chapter name is blank or empty * clean code (cherry picked from commit 41cc1fe7237a52c830e87c8261254b7f59922a6b)
This commit is contained in:
parent
d0810c90f5
commit
23a452f839
@ -162,14 +162,26 @@ class DownloadProvider(
|
||||
* @param chapterScanlator scanlator of the chapter to query
|
||||
*/
|
||||
fun getChapterDirName(chapterName: String, chapterScanlator: String?): String {
|
||||
val newChapterName = sanitizeChapterName(chapterName)
|
||||
return DiskUtil.buildValidFilename(
|
||||
when {
|
||||
chapterScanlator.isNullOrBlank().not() -> "${chapterScanlator}_$chapterName"
|
||||
else -> chapterName
|
||||
chapterScanlator.isNullOrBlank().not() -> "${chapterScanlator}_$newChapterName"
|
||||
else -> newChapterName
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the new name for the chapter (in case it's empty or blank)
|
||||
*
|
||||
* @param chapterName the name of the chapter
|
||||
*/
|
||||
private fun sanitizeChapterName(chapterName: String): String {
|
||||
return chapterName.ifBlank {
|
||||
"Chapter"
|
||||
}
|
||||
}
|
||||
|
||||
fun isChapterDirNameChanged(oldChapter: Chapter, newChapter: Chapter): Boolean {
|
||||
return oldChapter.name != newChapter.name ||
|
||||
oldChapter.scanlator?.takeIf { it.isNotBlank() } != newChapter.scanlator?.takeIf { it.isNotBlank() }
|
||||
|
Loading…
x
Reference in New Issue
Block a user