From bb89b72a819e1601608217374f1b5b368617432a Mon Sep 17 00:00:00 2001 From: len Date: Sat, 26 Nov 2016 12:34:54 +0100 Subject: [PATCH] Don't validate the page number and extension when saving a page --- .../java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt | 5 +++-- app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index cdb030f1b5..82d117da69 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -578,8 +578,9 @@ class ReaderPresenter : BasePresenter() { // Build destination file. val ext = MimeTypeMap.getSingleton().getExtensionFromMimeType(mime) ?: "jpg" - val filename = "${manga.title} - ${chapter.name} - ${page.index + 1}" - val destFile = File(destDir, DiskUtil.buildValidFilename(filename) + ".$ext") + val filename = DiskUtil.buildValidFilename( + "${manga.title} - ${chapter.name}") + " - ${page.index + 1}.$ext" + val destFile = File(destDir, filename) context.contentResolver.openInputStream(page.uri).use { input -> destFile.outputStream().use { output -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt index b3e3acda25..fa775183da 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt @@ -50,8 +50,8 @@ object DiskUtil { } } // Even though vfat allows 255 UCS-2 chars, we might eventually write to - // ext4 through a FUSE layer, so use that limit minus 5 reserved characters. - return sb.toString().take(250) + // ext4 through a FUSE layer, so use that limit minus 15 reserved characters. + return sb.toString().take(240) } /**