mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-12-04 16:00:10 +00:00
Compare commits
No commits in common. "c116b270b64f326d24a19d5678ef0dc18630ec1c" and "037616e271237a0a4a4d2b91b2243cf17da95bc5" have entirely different histories.
c116b270b6
...
037616e271
@ -1,11 +1,5 @@
|
|||||||
# 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.8
|
version=0.11.7
|
||||||
android_code_version=132
|
android_code_version=131
|
||||||
|
@ -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,17 +144,15 @@ 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()) {
|
_onNewValue.emit(filename to file)
|
||||||
error("Can't create file $file with new content")
|
|
||||||
}
|
}
|
||||||
_onNewValue.emit(filename to file)
|
|
||||||
}
|
}
|
||||||
}.joinAll()
|
}.joinAll()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user