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
## 0.11.8
* `Repos`:
* `Common`:
* Fixes in `FileKeyValueRepo`
## 0.11.7
* `Common`:

View File

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

View File

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