fix: import bundles on another thread

This commit is contained in:
Ax333l 2024-07-03 12:27:39 +02:00
parent 1ce56af3b1
commit d8248cc915
No known key found for this signature in database
GPG Key ID: D2B4D85271127D23

View File

@ -137,7 +137,7 @@ class PatchBundleRepository(
private fun addBundle(patchBundle: PatchBundleSource) =
_sources.update { it.toMutableMap().apply { put(patchBundle.uid, patchBundle) } }
suspend fun createLocal(patches: InputStream, integrations: InputStream?) {
suspend fun createLocal(patches: InputStream, integrations: InputStream?) = withContext(Dispatchers.Default) {
val uid = persistenceRepo.create("", SourceInfo.Local).uid
val bundle = LocalPatchBundle("", uid, directoryOf(uid))
@ -145,7 +145,7 @@ class PatchBundleRepository(
addBundle(bundle)
}
suspend fun createRemote(url: String, autoUpdate: Boolean) {
suspend fun createRemote(url: String, autoUpdate: Boolean) = withContext(Dispatchers.Default) {
val entity = persistenceRepo.create("", SourceInfo.from(url), autoUpdate)
addBundle(entity.load())
}