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