|
@@ -21,6 +21,8 @@ import eu.kanade.tachiyomi.ui.reader.loader.DownloadPageLoader
|
|
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
|
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
|
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
|
|
+import eu.kanade.tachiyomi.util.lang.byteSize
|
|
|
+import eu.kanade.tachiyomi.util.lang.takeBytes
|
|
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
|
|
import eu.kanade.tachiyomi.util.system.ImageUtil
|
|
|
import java.io.File
|
|
@@ -450,7 +452,7 @@ class ReaderPresenter(
|
|
|
// Build destination file.
|
|
|
val filenameSuffix = " - ${page.number}.${type.extension}"
|
|
|
val filename = DiskUtil.buildValidFilename(
|
|
|
- "${manga.title} - ${chapter.name}".take(MAX_FILE_NAME_LENGTH - filenameSuffix.length)
|
|
|
+ "${manga.title} - ${chapter.name}".takeBytes(MAX_FILE_NAME_BYTES - filenameSuffix.byteSize())
|
|
|
) + filenameSuffix
|
|
|
|
|
|
val destFile = File(directory, filename)
|
|
@@ -641,7 +643,7 @@ class ReaderPresenter(
|
|
|
}
|
|
|
|
|
|
companion object {
|
|
|
- // Safe max filename size is 255 bytes and 1 char = 2 bytes
|
|
|
- private const val MAX_FILE_NAME_LENGTH = 127
|
|
|
+ // Safe theoretical max filename size is 255 bytes and 1 char = 2-4 bytes (UTF-8)
|
|
|
+ private const val MAX_FILE_NAME_BYTES = 250
|
|
|
}
|
|
|
}
|