From 04cde568b1bd5d2b5e66959b2c36516f27a00834 Mon Sep 17 00:00:00 2001 From: daichi-matsumoto Date: Thu, 10 Oct 2024 02:17:21 +0900 Subject: [PATCH] fixed nits --- .../DownloadPostsRepository.android.kt | 16 +++++++++------- .../composeResources/files/versions.json | 4 ++-- gradle/libs.versions.toml | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/core/repository/src/androidMain/kotlin/me/matsumo/fanbox/core/repository/DownloadPostsRepository.android.kt b/core/repository/src/androidMain/kotlin/me/matsumo/fanbox/core/repository/DownloadPostsRepository.android.kt index ce0d2239..e951e3d2 100644 --- a/core/repository/src/androidMain/kotlin/me/matsumo/fanbox/core/repository/DownloadPostsRepository.android.kt +++ b/core/repository/src/androidMain/kotlin/me/matsumo/fanbox/core/repository/DownloadPostsRepository.android.kt @@ -150,7 +150,7 @@ class DownloadPostsRepositoryImpl( } override suspend fun getSaveDirectory(requestType: FanboxDownloadItems.RequestType): String { - return (getParentFile(requestType) ?: getOldParentFile(requestType)).filePath ?: "Unknown" + return (getParentFile(requestType) ?: getOldParentFile(requestType, true)).filePath ?: "Unknown" } private fun FanboxPostDetail.ImageItem.toDownloadItem(): FanboxDownloadItems.Item { @@ -208,7 +208,7 @@ class DownloadPostsRepositoryImpl( }.getOrNull() } - private fun getOldParentFile(requestType: FanboxDownloadItems.RequestType): UniFile { + private fun getOldParentFile(requestType: FanboxDownloadItems.RequestType, isDryRun: Boolean = false): UniFile { val environmentDir = when (requestType) { is FanboxDownloadItems.RequestType.Image -> Environment.DIRECTORY_PICTURES is FanboxDownloadItems.RequestType.File -> Environment.DIRECTORY_DOWNLOADS @@ -224,12 +224,14 @@ class DownloadPostsRepositoryImpl( val dir = File("${Environment.getExternalStorageDirectory().path}/$environmentDir", "FANBOX") val childDir = File(dir, child) - if (!dir.exists()) { - dir.mkdir() - } + if (!isDryRun) { + if (!dir.exists()) { + dir.mkdir() + } - if (child.isNotBlank() && !childDir.exists()) { - childDir.mkdir() + if (child.isNotBlank() && !childDir.exists()) { + childDir.mkdir() + } } return UniFile.fromFile(childDir)!! diff --git a/core/ui/src/commonMain/composeResources/files/versions.json b/core/ui/src/commonMain/composeResources/files/versions.json index dab9dfc1..ff2561d5 100644 --- a/core/ui/src/commonMain/composeResources/files/versions.json +++ b/core/ui/src/commonMain/composeResources/files/versions.json @@ -169,8 +169,8 @@ }, { "versionName": "2.1.7", - "versionCode": 43, - "date": "2024/10/08", + "versionCode": 46, + "date": "2024/10/10", "logJp": "・ダウンロード中のUIを改善\n・ダウンロードしたファイルの保存先を指定できるように変更\n・常にオリジナルサイズの画像をダウンロードできるオプションを用意\n・大きなファイルをダウンロードした際にアプリがクラッシュする問題を修正", "logEn": "・Improved the UI during downloading\n・Changed so that you can specify the destination to save downloaded files\n・Option to always download images in their original size\n・Fixed issue where app would crash when downloading large files" } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9f3f8705..6f578bb7 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] # Application versionName = "2.1.7" -versionCode = "44" +versionCode = "46" # SDK minSdk = "26"