mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-19 23:22:26 -07:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user