Sanitize the scanlator in chapter download folder names

A "/" in the scanlator nested the chapter in a folder of its own, where the download was never found again. Names built from the unsanitized scanlator are still looked up.
This commit is contained in:
AntsyLich
2026-10-07 01:05:30 +06:00
parent f027de8c2e
commit a5d584eeb0
@@ -168,10 +168,13 @@ class DownloadProvider(
chapterUrl: String,
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames.get(),
enableChapterNameHash: Boolean = libraryPreferences.enableChapterNameHash.get(),
sanitizeScanlator: Boolean = true,
): String {
return buildString {
if (!chapterScanlator.isNullOrBlank()) {
append(chapterScanlator + "_")
// A "/" in the scanlator would otherwise nest the chapter in a folder of its own
append(if (sanitizeScanlator) DiskUtil.buildValidFilename(chapterScanlator) else chapterScanlator)
append("_")
}
// Subtract 7 bytes for hash and underscore, 4 bytes for .cbz
@@ -226,11 +229,28 @@ class DownloadProvider(
)
}
// Scanlators weren't sanitized for a while. One with a "/" nested its folder, so it was never found anyway.
val unsanitizedScanlatorChapterDirNames = if (chapterScanlator != null && '/' !in chapterScanlator) {
booleanPairPermutation.map { (disallowNonAsciiFilenames, enableChapterNameHash) ->
getChapterDirName(
chapterName,
chapterScanlator,
chapterUrl,
disallowNonAsciiFilenames,
enableChapterNameHash,
sanitizeScanlator = false,
)
}
} else {
emptyList()
}
return buildSet {
// Chapter name without hash (unable to handle duplicate
// chapter names)
add(chapterNameV1)
addAll(othersChapterDirNames)
addAll(unsanitizedScanlatorChapterDirNames)
}
}