From 19f0175a56b00afd772d5d0c4909c49371a59bbe Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 22 Dec 2023 19:13:06 -0500 Subject: [PATCH] Don't use localized numbers for downloaded image filenames Probably fixes #10258 --- .../presentation/more/stats/StatsScreenContent.kt | 2 +- .../eu/kanade/tachiyomi/data/download/Downloader.kt | 11 ++++------- .../main/java/tachiyomi/core/util/system/ImageUtil.kt | 2 ++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenContent.kt b/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenContent.kt index 64f59280ca..a24b4cb640 100644 --- a/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenContent.kt +++ b/app/src/main/java/eu/kanade/presentation/more/stats/StatsScreenContent.kt @@ -140,7 +140,7 @@ private fun TrackerStats( val meanScoreStr = remember(data.trackedTitleCount, data.meanScore) { if (data.trackedTitleCount > 0 && !data.meanScore.isNaN()) { // All other numbers are localized in English - String.format(Locale.ENGLISH, "%.2f ★", data.meanScore) + "%.2f ★".format(Locale.ENGLISH, data.meanScore) } else { notApplicable } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 30f11c4d15..8b54cfabd9 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -59,6 +59,7 @@ import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import java.io.BufferedOutputStream import java.io.File +import java.util.Locale import java.util.zip.CRC32 import java.util.zip.ZipEntry import java.util.zip.ZipOutputStream @@ -422,7 +423,7 @@ class Downloader( } val digitCount = (download.pages?.size ?: 0).toString().length.coerceAtLeast(3) - val filename = String.format("%0${digitCount}d", page.number) + val filename = "%0${digitCount}d".format(Locale.ENGLISH, page.number) val tmpFile = tmpDir.findFile("$filename.tmp") // Delete temp file if it exists @@ -537,7 +538,7 @@ class Downloader( if (!downloadPreferences.splitTallImages().get()) return try { - val filenamePrefix = String.format("%03d", page.number) + val filenamePrefix = "%03d".format(Locale.ENGLISH, page.number) val imageFile = tmpDir.listFiles()?.firstOrNull { it.name.orEmpty().startsWith(filenamePrefix) } ?: error(context.stringResource(MR.strings.download_notifier_split_page_not_found, page.number)) @@ -579,11 +580,7 @@ class Downloader( else -> true } } - if (downloadedImagesCount != downloadPageCount) { - return false - } - - return true + return downloadedImagesCount == downloadPageCount } /** diff --git a/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt b/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt index 0aa7f9f59c..68da52505b 100644 --- a/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt +++ b/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt @@ -31,6 +31,7 @@ import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.InputStream import java.net.URLConnection +import java.util.Locale import kotlin.math.abs import kotlin.math.max import kotlin.math.min @@ -274,6 +275,7 @@ object ImageUtil { } private fun splitImageName(filenamePrefix: String, index: Int) = "${filenamePrefix}__${"%03d".format( + Locale.ENGLISH, index + 1, )}.jpg"