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,
|
chapterUrl: String,
|
||||||
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames.get(),
|
disallowNonAsciiFilenames: Boolean = libraryPreferences.disallowNonAsciiFilenames.get(),
|
||||||
enableChapterNameHash: Boolean = libraryPreferences.enableChapterNameHash.get(),
|
enableChapterNameHash: Boolean = libraryPreferences.enableChapterNameHash.get(),
|
||||||
|
sanitizeScanlator: Boolean = true,
|
||||||
): String {
|
): String {
|
||||||
return buildString {
|
return buildString {
|
||||||
if (!chapterScanlator.isNullOrBlank()) {
|
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
|
// 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 {
|
return buildSet {
|
||||||
// Chapter name without hash (unable to handle duplicate
|
// Chapter name without hash (unable to handle duplicate
|
||||||
// chapter names)
|
// chapter names)
|
||||||
add(chapterNameV1)
|
add(chapterNameV1)
|
||||||
addAll(othersChapterDirNames)
|
addAll(othersChapterDirNames)
|
||||||
|
addAll(unsanitizedScanlatorChapterDirNames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user