Use different file stores based on config

This commit is contained in:
eikek
2022-03-07 17:21:38 +01:00
parent c812ea1009
commit e82b00c582
10 changed files with 211 additions and 9 deletions

View File

@ -646,6 +646,41 @@ Docpell Update Check
# restrict file types that should be handed over to processing.
# By default all files are allowed.
valid-mime-types = [ ]
# The id of an enabled store from the `stores` array that should
# be used.
#
# IMPORTANT NOTE: All nodes must have the exact same file store
# configuration!
default-store = "database"
# A list of possible file stores. Each entry must have a unique
# id. The `type` is one of: default-database, filesystem, s3.
#
# The enabled property serves currently to define target stores
# for te "copy files" task. All stores with enabled=false are
# removed from the list. The `default-store` must be enabled.
stores = {
database =
{ enabled = true
type = "default-database"
}
filesystem =
{ enabled = false
type = "file-system"
directory = "/some/directory"
}
minio =
{ enabled = false
type = "s3"
endpoint = "http://localhost:9000"
access-key = "username"
secret-key = "password"
bucket = "docspell"
}
}
}
# Configuration of the full-text search engine.

View File

@ -19,8 +19,6 @@ import pureconfig.generic.auto._
import yamusca.imports._
object ConfigFile {
import Implicits._
def loadConfig[F[_]: Async](args: List[String]): F[Config] = {
val logger = docspell.logging.getLogger[F]
ConfigFactory
@ -51,6 +49,7 @@ object ConfigFile {
Validation.failWhen(
cfg => cfg.updateCheck.enabled && cfg.updateCheck.subject.els.isEmpty,
"No subject given for enabled update check!"
)
),
Validation(cfg => cfg.files.validate.map(_ => cfg))
)
}

View File

@ -16,7 +16,6 @@ import docspell.common.Pools
import docspell.joex.routes._
import docspell.pubsub.naive.NaivePubSub
import docspell.store.Store
import docspell.store.file.FileRepositoryConfig
import docspell.store.records.RInternalSetting
import org.http4s.HttpApp
@ -42,7 +41,7 @@ object JoexServer {
store <- Store.create[F](
cfg.jdbc,
FileRepositoryConfig.Database(cfg.files.chunkSize),
cfg.files.toFileRepositoryConfig,
pools.connectEC
)
settings <- Resource.eval(store.transact(RInternalSetting.create))