mirror of
https://gitlab.computer.surgery/matrix/grapevine.git
synced 2025-12-17 15:51:23 +01:00
separate media and database paths
The primary motivation for this change is to support databases that don't take a path, e.g. out of process databases. This configuration structure leaves the door open for other media storage mechanisms in the future, such as S3. It's also structured to avoid `#[serde(flatten)]` so that we can use `#[serde(deny_unknown_fields)]`.
This commit is contained in:
parent
ae920fdbe8
commit
5a5608e088
6 changed files with 82 additions and 8 deletions
|
|
@ -44,7 +44,6 @@ pub(crate) struct Config {
|
|||
|
||||
pub(crate) server_discovery: ServerDiscovery,
|
||||
pub(crate) database: DatabaseConfig,
|
||||
#[serde(default)]
|
||||
pub(crate) media: MediaConfig,
|
||||
#[serde(default)]
|
||||
pub(crate) federation: FederationConfig,
|
||||
|
|
@ -74,13 +73,27 @@ pub(crate) struct Config {
|
|||
pub(crate) emergency_password: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Default)]
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct MediaConfig {
|
||||
pub(crate) backend: MediaBackendConfig,
|
||||
|
||||
#[serde(default)]
|
||||
pub(crate) allow_unauthenticated_access: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields, tag = "type", rename_all = "snake_case")]
|
||||
pub(crate) enum MediaBackendConfig {
|
||||
Filesystem(MediaFilesystemConfig),
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
pub(crate) struct MediaFilesystemConfig {
|
||||
pub(crate) path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(deny_unknown_fields, default)]
|
||||
pub(crate) struct CacheConfig {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ use trust_dns_resolver::TokioAsyncResolver;
|
|||
|
||||
use crate::{
|
||||
api::server_server::FedDest,
|
||||
config::{MediaBackendConfig, MediaFilesystemConfig},
|
||||
observability::FilterReloadHandles,
|
||||
service::media::MediaFileKey,
|
||||
services,
|
||||
|
|
@ -602,10 +603,11 @@ impl Service {
|
|||
}
|
||||
|
||||
pub(crate) fn get_media_folder(&self) -> PathBuf {
|
||||
let mut r = PathBuf::new();
|
||||
r.push(self.config.database.path.clone());
|
||||
r.push("media");
|
||||
r
|
||||
let MediaBackendConfig::Filesystem(MediaFilesystemConfig {
|
||||
path,
|
||||
}) = &self.config.media.backend;
|
||||
|
||||
path.clone()
|
||||
}
|
||||
|
||||
pub(crate) fn get_media_file(&self, key: &MediaFileKey) -> PathBuf {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue