mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-03 15:30:10 +00:00
Compare commits
3 Commits
037616e271
...
c116b270b6
Author | SHA1 | Date | |
---|---|---|---|
c116b270b6 | |||
aa2d598689 | |||
5ef3bb746b |
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.11.8
|
||||||
|
|
||||||
|
* `Repos`:
|
||||||
|
* `Common`:
|
||||||
|
* Fixes in `FileKeyValueRepo`
|
||||||
|
|
||||||
## 0.11.7
|
## 0.11.7
|
||||||
|
|
||||||
* `Common`:
|
* `Common`:
|
||||||
|
@ -14,5 +14,5 @@ crypto_js_version=4.1.1
|
|||||||
# Project data
|
# Project data
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=0.11.7
|
version=0.11.8
|
||||||
android_code_version=131
|
android_code_version=132
|
||||||
|
@ -99,7 +99,9 @@ class FileWriteKeyValueRepo(
|
|||||||
override val onValueRemoved: Flow<String> = _onValueRemoved.asSharedFlow()
|
override val onValueRemoved: Flow<String> = _onValueRemoved.asSharedFlow()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
folder.mkdirs()
|
if (!folder.mkdirs() && !folder.exists()) {
|
||||||
|
error("Unable to create folder ${folder.absolutePath}")
|
||||||
|
}
|
||||||
filesChangedProcessingScope ?.let {
|
filesChangedProcessingScope ?.let {
|
||||||
it.launch {
|
it.launch {
|
||||||
try {
|
try {
|
||||||
@ -144,15 +146,17 @@ class FileWriteKeyValueRepo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun set(toSet: Map<String, File>) {
|
override suspend fun set(toSet: Map<String, File>) {
|
||||||
supervisorScope {
|
val scope = CoroutineScope(currentCoroutineContext())
|
||||||
toSet.map { (filename, fileSource) ->
|
toSet.map { (filename, fileSource) ->
|
||||||
launch {
|
scope.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)
|
||||||
_onNewValue.emit(filename to file)
|
if (!file.exists()) {
|
||||||
|
error("Can't create file $file with new content")
|
||||||
}
|
}
|
||||||
|
_onNewValue.emit(filename to file)
|
||||||
}
|
}
|
||||||
}.joinAll()
|
}.joinAll()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user