mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-20 15:47:15 +00:00
commit
a56cd3dddd
10
CHANGELOG.md
10
CHANGELOG.md
@ -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`:
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -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 ->
|
||||||
|
Loading…
Reference in New Issue
Block a user