From d1fa0242fa9a6bfe8814d4d01d597462a2dab5d9 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 19 Jan 2022 17:22:04 +0600 Subject: [PATCH] temporal progress --- .../server/BinaryServerContentStorage.kt | 2 +- .../server/PartDataContentDownloading.kt | 22 +++++++++++++++++++ .../server/ServerContentStorageAggregator.kt | 1 + .../server/ServerContentStorageWrapper.kt | 2 ++ .../{ => storage}/ServerContentStorage.kt | 2 +- .../{ => storage}/ServerReadContentStorage.kt | 2 +- .../ServerWriteContentStorage.kt | 2 +- .../text/server/TextServerContentStorage.kt | 2 +- .../publication/server/PublicationManager.kt | 2 +- .../java/dev/inmo/postssystem/server/DI.kt | 2 +- 10 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/PartDataContentDownloading.kt rename features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/{ => storage}/ServerContentStorage.kt (79%) rename features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/{ => storage}/ServerReadContentStorage.kt (81%) rename features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/{ => storage}/ServerWriteContentStorage.kt (76%) diff --git a/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt b/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt index 9fda299e..75a163b6 100644 --- a/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt +++ b/features/content/binary/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/binary/server/BinaryServerContentStorage.kt @@ -4,7 +4,7 @@ import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.UpdatedValuePair import dev.inmo.postssystem.features.content.binary.common.DefaultBinaryContent import dev.inmo.postssystem.features.content.common.* -import dev.inmo.postssystem.features.content.server.ServerContentStorage +import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage import dev.inmo.postssystem.features.files.common.* import dev.inmo.postssystem.features.files.common.storage.FilesStorage import kotlinx.coroutines.flow.Flow diff --git a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/PartDataContentDownloading.kt b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/PartDataContentDownloading.kt new file mode 100644 index 00000000..aeeefaed --- /dev/null +++ b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/PartDataContentDownloading.kt @@ -0,0 +1,22 @@ +package dev.inmo.postssystem.features.content.server + +import com.benasher44.uuid.uuid4 +import dev.inmo.micro_utils.common.FileName +import io.ktor.http.content.PartData +import java.io.File + +suspend fun PartData.loadContent() { + when (this) { + is PartData.FormItem -> TODO() + is PartData.FileItem -> { + val fileName = FileName(originalFileName ?: return null) + val downloadTo = File.createTempFile( + uuid4().toString(), + fileName.extension + ) + headers["data"] + return + } + is PartData.BinaryItem -> return null/* Currently impossible state */ + } +} diff --git a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageAggregator.kt b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageAggregator.kt index de8812c3..94de5fd3 100644 --- a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageAggregator.kt +++ b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageAggregator.kt @@ -3,6 +3,7 @@ package dev.inmo.postssystem.features.content.server import dev.inmo.micro_utils.pagination.* import dev.inmo.micro_utils.repos.UpdatedValuePair import dev.inmo.postssystem.features.content.common.* +import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow diff --git a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageWrapper.kt b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageWrapper.kt index 463d2e81..590f034f 100644 --- a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageWrapper.kt +++ b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorageWrapper.kt @@ -2,6 +2,8 @@ package dev.inmo.postssystem.features.content.server import dev.inmo.micro_utils.repos.UpdatedValuePair import dev.inmo.postssystem.features.content.common.* +import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage +import dev.inmo.postssystem.features.content.server.storage.ServerReadContentStorage import kotlinx.coroutines.flow.Flow import kotlin.reflect.KClass diff --git a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorage.kt b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerContentStorage.kt similarity index 79% rename from features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorage.kt rename to features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerContentStorage.kt index 75498560..bb082488 100644 --- a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerContentStorage.kt +++ b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerContentStorage.kt @@ -1,4 +1,4 @@ -package dev.inmo.postssystem.features.content.server +package dev.inmo.postssystem.features.content.server.storage import dev.inmo.micro_utils.repos.CRUDRepo import dev.inmo.postssystem.features.content.common.* diff --git a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerReadContentStorage.kt b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerReadContentStorage.kt similarity index 81% rename from features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerReadContentStorage.kt rename to features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerReadContentStorage.kt index 5375edd5..6c542426 100644 --- a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerReadContentStorage.kt +++ b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerReadContentStorage.kt @@ -1,4 +1,4 @@ -package dev.inmo.postssystem.features.content.server +package dev.inmo.postssystem.features.content.server.storage import dev.inmo.micro_utils.repos.ReadCRUDRepo import dev.inmo.postssystem.features.content.common.ContentId diff --git a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerWriteContentStorage.kt b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerWriteContentStorage.kt similarity index 76% rename from features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerWriteContentStorage.kt rename to features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerWriteContentStorage.kt index fb3de668..982e3a45 100644 --- a/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/ServerWriteContentStorage.kt +++ b/features/content/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/server/storage/ServerWriteContentStorage.kt @@ -1,4 +1,4 @@ -package dev.inmo.postssystem.features.content.server +package dev.inmo.postssystem.features.content.server.storage import dev.inmo.micro_utils.repos.WriteCRUDRepo import dev.inmo.postssystem.features.content.common.* diff --git a/features/content/text/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/text/server/TextServerContentStorage.kt b/features/content/text/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/text/server/TextServerContentStorage.kt index b54caf58..2ee63418 100644 --- a/features/content/text/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/text/server/TextServerContentStorage.kt +++ b/features/content/text/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/content/text/server/TextServerContentStorage.kt @@ -5,7 +5,7 @@ import dev.inmo.micro_utils.repos.exposed.AbstractExposedCRUDRepo import dev.inmo.micro_utils.repos.exposed.initTable import dev.inmo.postssystem.features.content.common.ContentId import dev.inmo.postssystem.features.content.common.RegisteredContent -import dev.inmo.postssystem.features.content.server.ServerContentStorage +import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage import dev.inmo.postssystem.features.content.text.common.TextContent import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.statements.InsertStatement diff --git a/features/publication/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/publication/server/PublicationManager.kt b/features/publication/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/publication/server/PublicationManager.kt index d70feba5..9cfd2de0 100644 --- a/features/publication/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/publication/server/PublicationManager.kt +++ b/features/publication/server/src/jvmMain/kotlin/dev/inmo/postssystem/features/publication/server/PublicationManager.kt @@ -1,7 +1,7 @@ package dev.inmo.postssystem.features.publication.server import dev.inmo.micro_utils.coroutines.asyncSafelyWithoutExceptions -import dev.inmo.postssystem.features.content.server.ServerReadContentStorage +import dev.inmo.postssystem.features.content.server.storage.ServerReadContentStorage import dev.inmo.postssystem.features.posts.common.PostId import dev.inmo.postssystem.features.posts.server.ServerReadPostsStorage import kotlinx.coroutines.* diff --git a/server/src/main/java/dev/inmo/postssystem/server/DI.kt b/server/src/main/java/dev/inmo/postssystem/server/DI.kt index a2c6390a..2a2265a7 100644 --- a/server/src/main/java/dev/inmo/postssystem/server/DI.kt +++ b/server/src/main/java/dev/inmo/postssystem/server/DI.kt @@ -28,7 +28,7 @@ import dev.inmo.postssystem.features.common.common.* import dev.inmo.postssystem.features.content.binary.common.BinaryContentSerializerModuleConfigurator import dev.inmo.postssystem.features.content.binary.server.BinaryServerContentStorage import dev.inmo.postssystem.features.content.common.* -import dev.inmo.postssystem.features.content.server.ServerContentStorage +import dev.inmo.postssystem.features.content.server.storage.ServerContentStorage import dev.inmo.postssystem.features.content.server.ServerContentStorageAggregator import dev.inmo.postssystem.features.content.text.common.TextContentSerializerModuleConfigurator import dev.inmo.postssystem.features.content.text.server.TextServerContentStorage