Compare commits

..

No commits in common. "c116b270b64f326d24a19d5678ef0dc18630ec1c" and "037616e271237a0a4a4d2b91b2243cf17da95bc5" have entirely different histories.

3 changed files with 10 additions and 20 deletions

View File

@ -1,11 +1,5 @@
# Changelog # Changelog
## 0.11.8
* `Repos`:
* `Common`:
* Fixes in `FileKeyValueRepo`
## 0.11.7 ## 0.11.7
* `Common`: * `Common`:

View File

@ -14,5 +14,5 @@ crypto_js_version=4.1.1
# Project data # Project data
group=dev.inmo group=dev.inmo
version=0.11.8 version=0.11.7
android_code_version=132 android_code_version=131

View File

@ -99,9 +99,7 @@ class FileWriteKeyValueRepo(
override val onValueRemoved: Flow<String> = _onValueRemoved.asSharedFlow() override val onValueRemoved: Flow<String> = _onValueRemoved.asSharedFlow()
init { init {
if (!folder.mkdirs() && !folder.exists()) { folder.mkdirs()
error("Unable to create folder ${folder.absolutePath}")
}
filesChangedProcessingScope ?.let { filesChangedProcessingScope ?.let {
it.launch { it.launch {
try { try {
@ -146,18 +144,16 @@ class FileWriteKeyValueRepo(
} }
override suspend fun set(toSet: Map<String, File>) { override suspend fun set(toSet: Map<String, File>) {
val scope = CoroutineScope(currentCoroutineContext()) supervisorScope {
toSet.map { (filename, fileSource) -> toSet.map { (filename, fileSource) ->
scope.launch { launch {
val file = File(folder, filename) val file = File(folder, filename)
file.delete() file.delete()
fileSource.copyTo(file, overwrite = true) fileSource.copyTo(file, overwrite = true)
if (!file.exists()) {
error("Can't create file $file with new content")
}
_onNewValue.emit(filename to file) _onNewValue.emit(filename to file)
} }
}
}.joinAll() }.joinAll()
} }