From d0446850aeb76f242d42d99b74433238a80191f7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 27 Dec 2021 15:45:44 +0600 Subject: [PATCH 1/5] start 0.8.9 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c255949536c..ebacebfab1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.8.9 + ## 0.8.8 * `Versions`: diff --git a/gradle.properties b/gradle.properties index df127369aba..11b070657eb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -45,5 +45,5 @@ dokka_version=1.5.31 # Project data group=dev.inmo -version=0.8.8 -android_code_version=88 +version=0.8.9 +android_code_version=89 From e639ae172ba7dce86cf50922dff9da2ea1b5b4bf Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 27 Dec 2021 15:55:05 +0600 Subject: [PATCH 2/5] Fixes in uniloadMultipart --- CHANGELOG.md | 4 ++++ .../ktor/server/ServerRoutingShortcuts.kt | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebacebfab1e..007b5c2d1a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.8.9 +* `Ktor`: + * `Server`: + * Fixes in `uniloadMultipart` + ## 0.8.8 * `Versions`: diff --git a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt index 344092679c9..fac6c49af08 100644 --- a/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt +++ b/ktor/server/src/jvmMain/kotlin/dev/inmo/micro_utils/ktor/server/ServerRoutingShortcuts.kt @@ -180,7 +180,13 @@ suspend fun ApplicationCall.uniloadMultipartFile( "bytes" -> { val name = FileName(it.originalFileName ?: error("File name is unknown for default part")) resultInput = MPPFile.createTempFile( - name.nameWithoutExtension, + name.nameWithoutExtension.let { + var resultName = it + while (resultName.length < 3) { + resultName += "_" + } + resultName + }, ".${name.extension}" ).apply { outputStream().use { fileStream -> @@ -216,7 +222,13 @@ suspend fun ApplicationCall.uniloadMultipartFile( if (it.name == "bytes") { val name = FileName(it.originalFileName ?: error("File name is unknown for default part")) resultInput = MPPFile.createTempFile( - name.nameWithoutExtension, + name.nameWithoutExtension.let { + var resultName = it + while (resultName.length < 3) { + resultName += "_" + } + resultName + }, ".${name.extension}" ).apply { outputStream().use { fileStream -> From 8b39882e834aba1692675a70baa427691bdda346 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 27 Dec 2021 15:57:55 +0600 Subject: [PATCH 3/5] fixes in DefaultUpdatableStatesMachine --- CHANGELOG.md | 3 +++ .../inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 007b5c2d1a2..f538f5039bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ * `Server`: * Fixes in `uniloadMultipart` +* `FSM`: + * Fixes in `DefaultUpdatableStatesMachine` + ## 0.8.8 * `Versions`: diff --git a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt index deadfb62324..76fccd49c88 100644 --- a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt +++ b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt @@ -28,12 +28,12 @@ open class DefaultUpdatableStatesMachine( override suspend fun performStateUpdate(previousState: Optional, actualState: T, scope: CoroutineScope) { statesJobsMutex.withLock { - if (previousState.dataOrNull() != actualState) { + if (compare(previousState, actualState)) { statesJobs[actualState] ?.cancel() } val job = previousState.mapOnPresented { statesJobs.remove(it) - } ?: scope.launch { + } ?.takeIf { it.isActive } ?: scope.launch { performUpdate(actualState) }.also { job -> job.invokeOnCompletion { _ -> @@ -52,6 +52,8 @@ open class DefaultUpdatableStatesMachine( } } + protected suspend fun compare(previous: Optional, new: T): Boolean = previous.dataOrNull() != new + override suspend fun updateChain(currentState: T, newState: T) { statesManager.update(currentState, newState) } From 612cf40b5f15e38ffd7b5da79c1da142c41378e8 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 27 Dec 2021 16:00:07 +0600 Subject: [PATCH 4/5] small hotfix --- .../dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt index 76fccd49c88..8d5a53f41bb 100644 --- a/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt +++ b/fsm/common/src/commonMain/kotlin/dev/inmo/micro_utils/fsm/common/UpdatableStatesMachine.kt @@ -52,7 +52,7 @@ open class DefaultUpdatableStatesMachine( } } - protected suspend fun compare(previous: Optional, new: T): Boolean = previous.dataOrNull() != new + protected open suspend fun compare(previous: Optional, new: T): Boolean = previous.dataOrNull() != new override suspend fun updateChain(currentState: T, newState: T) { statesManager.update(currentState, newState) From 419e7070ee7094141280bb0915e4bf26b8f6af04 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 27 Dec 2021 17:02:00 +0600 Subject: [PATCH 5/5] more fixes to god of fixes --- CHANGELOG.md | 3 ++- .../inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f538f5039bd..9a1c7c583fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ * `Ktor`: * `Server`: * Fixes in `uniloadMultipart` - + * `Client`: + * Fixes in `unimultipart` * `FSM`: * Fixes in `DefaultUpdatableStatesMachine` diff --git a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt index e6725a2ed24..0cc8af023aa 100644 --- a/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt +++ b/ktor/client/src/commonMain/kotlin/dev/inmo/micro_utils/ktor/client/StandardHttpClientGetPost.kt @@ -140,7 +140,7 @@ suspend fun HttpClient.unimultipart( inputProvider, Headers.build { append(HttpHeaders.ContentType, mimetype) - append(HttpHeaders.ContentDisposition, "filename=$filename") + append(HttpHeaders.ContentDisposition, "filename=\"$filename\"") dataHeadersBuilder() } )