From 5ef3bb746b16b8a8fa5a889bdca8a9548cd7e337 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 Jun 2022 14:12:12 +0600 Subject: [PATCH 1/2] start 0.11.8 --- CHANGELOG.md | 2 ++ gradle.properties | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5daa01e3045..0000a728a4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +## 0.11.8 + ## 0.11.7 * `Common`: diff --git a/gradle.properties b/gradle.properties index d4794a30290..56e49263af6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -14,5 +14,5 @@ crypto_js_version=4.1.1 # Project data group=dev.inmo -version=0.11.7 -android_code_version=131 +version=0.11.8 +android_code_version=132 From aa2d598689e7c4f78165eb1c814d3f158ef6afb7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 28 Jun 2022 14:13:04 +0600 Subject: [PATCH 2/2] fixes in FileKeyValueRepo --- CHANGELOG.md | 4 ++++ .../micro_utils/repos/FileKeyValueRepo.kt | 20 +++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0000a728a4f..3e07952d145 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.11.8 +* `Repos`: + * `Common`: + * Fixes in `FileKeyValueRepo` + ## 0.11.7 * `Common`: diff --git a/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileKeyValueRepo.kt b/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileKeyValueRepo.kt index 2b9d9163ff7..5c7fb0121b3 100644 --- a/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileKeyValueRepo.kt +++ b/repos/common/src/jvmMain/kotlin/dev/inmo/micro_utils/repos/FileKeyValueRepo.kt @@ -99,7 +99,9 @@ class FileWriteKeyValueRepo( override val onValueRemoved: Flow = _onValueRemoved.asSharedFlow() init { - folder.mkdirs() + if (!folder.mkdirs() && !folder.exists()) { + error("Unable to create folder ${folder.absolutePath}") + } filesChangedProcessingScope ?.let { it.launch { try { @@ -144,15 +146,17 @@ class FileWriteKeyValueRepo( } override suspend fun set(toSet: Map) { - supervisorScope { - toSet.map { (filename, fileSource) -> - launch { - val file = File(folder, filename) + val scope = CoroutineScope(currentCoroutineContext()) + toSet.map { (filename, fileSource) -> + scope.launch { + val file = File(folder, filename) - file.delete() - fileSource.copyTo(file, overwrite = true) - _onNewValue.emit(filename to file) + file.delete() + fileSource.copyTo(file, overwrite = true) + if (!file.exists()) { + error("Can't create file $file with new content") } + _onNewValue.emit(filename to file) } }.joinAll() }