Merge pull request #120 from InsanusMokrassar/0.8.9

0.8.9
This commit is contained in:
InsanusMokrassar 2021-12-27 17:02:16 +06:00 committed by GitHub
commit a56cd3dddd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 7 deletions

View File

@ -1,5 +1,15 @@
# Changelog # Changelog
## 0.8.9
* `Ktor`:
* `Server`:
* Fixes in `uniloadMultipart`
* `Client`:
* Fixes in `unimultipart`
* `FSM`:
* Fixes in `DefaultUpdatableStatesMachine`
## 0.8.8 ## 0.8.8
* `Versions`: * `Versions`:

View File

@ -28,12 +28,12 @@ open class DefaultUpdatableStatesMachine<T : State>(
override suspend fun performStateUpdate(previousState: Optional<T>, actualState: T, scope: CoroutineScope) { override suspend fun performStateUpdate(previousState: Optional<T>, actualState: T, scope: CoroutineScope) {
statesJobsMutex.withLock { statesJobsMutex.withLock {
if (previousState.dataOrNull() != actualState) { if (compare(previousState, actualState)) {
statesJobs[actualState] ?.cancel() statesJobs[actualState] ?.cancel()
} }
val job = previousState.mapOnPresented { val job = previousState.mapOnPresented {
statesJobs.remove(it) statesJobs.remove(it)
} ?: scope.launch { } ?.takeIf { it.isActive } ?: scope.launch {
performUpdate(actualState) performUpdate(actualState)
}.also { job -> }.also { job ->
job.invokeOnCompletion { _ -> job.invokeOnCompletion { _ ->
@ -52,6 +52,8 @@ open class DefaultUpdatableStatesMachine<T : State>(
} }
} }
protected open suspend fun compare(previous: Optional<T>, new: T): Boolean = previous.dataOrNull() != new
override suspend fun updateChain(currentState: T, newState: T) { override suspend fun updateChain(currentState: T, newState: T) {
statesManager.update(currentState, newState) statesManager.update(currentState, newState)
} }

View File

@ -45,5 +45,5 @@ dokka_version=1.5.31
# Project data # Project data
group=dev.inmo group=dev.inmo
version=0.8.8 version=0.8.9
android_code_version=88 android_code_version=89

View File

@ -140,7 +140,7 @@ suspend fun <ResultType> HttpClient.unimultipart(
inputProvider, inputProvider,
Headers.build { Headers.build {
append(HttpHeaders.ContentType, mimetype) append(HttpHeaders.ContentType, mimetype)
append(HttpHeaders.ContentDisposition, "filename=$filename") append(HttpHeaders.ContentDisposition, "filename=\"$filename\"")
dataHeadersBuilder() dataHeadersBuilder()
} }
) )

View File

@ -180,7 +180,13 @@ suspend fun <T> ApplicationCall.uniloadMultipartFile(
"bytes" -> { "bytes" -> {
val name = FileName(it.originalFileName ?: error("File name is unknown for default part")) val name = FileName(it.originalFileName ?: error("File name is unknown for default part"))
resultInput = MPPFile.createTempFile( resultInput = MPPFile.createTempFile(
name.nameWithoutExtension, name.nameWithoutExtension.let {
var resultName = it
while (resultName.length < 3) {
resultName += "_"
}
resultName
},
".${name.extension}" ".${name.extension}"
).apply { ).apply {
outputStream().use { fileStream -> outputStream().use { fileStream ->
@ -216,7 +222,13 @@ suspend fun ApplicationCall.uniloadMultipartFile(
if (it.name == "bytes") { if (it.name == "bytes") {
val name = FileName(it.originalFileName ?: error("File name is unknown for default part")) val name = FileName(it.originalFileName ?: error("File name is unknown for default part"))
resultInput = MPPFile.createTempFile( resultInput = MPPFile.createTempFile(
name.nameWithoutExtension, name.nameWithoutExtension.let {
var resultName = it
while (resultName.length < 3) {
resultName += "_"
}
resultName
},
".${name.extension}" ".${name.extension}"
).apply { ).apply {
outputStream().use { fileStream -> outputStream().use { fileStream ->