small refactoring

This commit is contained in:
InsanusMokrassar 2020-11-27 11:45:29 +06:00
parent f685175285
commit 4986bed5bc

View File

@ -11,8 +11,8 @@ import kotlinx.serialization.json.Json
private val format = Json { ignoreUnknownKeys = true }
class BinaryBusinessContentRepoContentAdapter(
private val dataStore: KeyValueRepo<String, String>,
private val filesStore: KeyValueRepo<String, ByteArray>,
private val dataStore: KeyValueRepo<ContentId, String>,
private val filesStore: KeyValueRepo<ContentId, ByteArray>,
private val removeOnAbsentInOneOfStores: Boolean = false
) : BusinessContentRepoContentAdapter {
override val type: AdapterType
@ -20,7 +20,7 @@ class BinaryBusinessContentRepoContentAdapter(
override suspend fun storeContent(contentId: ContentId, content: Content): Boolean {
(content as? BinaryContent) ?.also {
filesStore.set(it.originalFileName, it.dataAllocator())
filesStore.set(contentId, it.dataAllocator())
dataStore.set(
contentId,
format.encodeToString(BinaryContent.serializer(), it.copy { ByteArray(0) })