mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Use different file stores based on config
This commit is contained in:
@ -358,6 +358,41 @@ docspell.server {
|
||||
# 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -24,12 +24,18 @@ import scodec.bits.ByteVector
|
||||
object ConfigFile {
|
||||
private[this] val unsafeLogger = docspell.logging.unsafeLogger
|
||||
|
||||
// IntelliJ is wrong, this is required
|
||||
import Implicits._
|
||||
|
||||
def loadConfig[F[_]: Async](args: List[String]): F[Config] = {
|
||||
val logger = docspell.logging.getLogger[F]
|
||||
val validate =
|
||||
Validation.of(generateSecretIfEmpty, duplicateOpenIdProvider, signKeyVsUserUrl)
|
||||
Validation.of(
|
||||
generateSecretIfEmpty,
|
||||
duplicateOpenIdProvider,
|
||||
signKeyVsUserUrl,
|
||||
filesValidate
|
||||
)
|
||||
ConfigFactory
|
||||
.default[F, Config](logger, "docspell.server")(args, validate)
|
||||
}
|
||||
@ -97,4 +103,7 @@ object ConfigFile {
|
||||
.map(checkProvider)
|
||||
)
|
||||
}
|
||||
|
||||
def filesValidate: Validation[Config] =
|
||||
Validation(cfg => cfg.backend.files.validate.map(_ => cfg))
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import docspell.restserver.http4s.InternalHeader
|
||||
import docspell.restserver.ws.OutputEvent.KeepAlive
|
||||
import docspell.restserver.ws.OutputEvent
|
||||
import docspell.store.Store
|
||||
import docspell.store.file.FileRepositoryConfig
|
||||
import docspell.store.records.RInternalSetting
|
||||
import org.http4s._
|
||||
import org.http4s.blaze.client.BlazeClientBuilder
|
||||
@ -74,7 +73,7 @@ object RestServer {
|
||||
httpClient <- BlazeClientBuilder[F].resource
|
||||
store <- Store.create[F](
|
||||
cfg.backend.jdbc,
|
||||
FileRepositoryConfig.Database(cfg.backend.files.chunkSize),
|
||||
cfg.backend.files.toFileRepositoryConfig,
|
||||
pools.connectEC
|
||||
)
|
||||
setting <- Resource.eval(store.transact(RInternalSetting.create))
|
||||
|
Reference in New Issue
Block a user