Fix unified config in web

This commit is contained in:
Olivier 'reivilibre' 2022-04-06 21:50:17 +01:00
parent df356da498
commit 8ac99c154f
1 changed files with 9 additions and 3 deletions

View File

@ -16,7 +16,13 @@ pub struct SeedCollectionConfig {
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
pub struct WebConfig { pub struct WebConfig {
pub web: WebOnlyConfig, pub web: WebOnlyConfig,
pub index: BackendConfig, pub index: IndexConfig,
}
#[derive(Debug, Clone, Deserialize)]
pub struct IndexConfig {
pub backend: BackendConfig,
// TODO icon_store
} }
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
@ -36,7 +42,7 @@ impl WebConfig {
let mut web_config: WebConfig = let mut web_config: WebConfig =
ron::de::from_bytes(&file_bytes).context("Failed to parse web config")?; ron::de::from_bytes(&file_bytes).context("Failed to parse web config")?;
match &mut web_config.index { match &mut web_config.index.backend {
BackendConfig::Tantivy(tantivy) => { BackendConfig::Tantivy(tantivy) => {
tantivy.index_dir = config_dir.join(&tantivy.index_dir); tantivy.index_dir = config_dir.join(&tantivy.index_dir);
} }
@ -48,7 +54,7 @@ impl WebConfig {
pub fn open_indexer_backend(&self) -> anyhow::Result<Box<dyn Backend>> { pub fn open_indexer_backend(&self) -> anyhow::Result<Box<dyn Backend>> {
// TODO deduplicate with the indexer crate // TODO deduplicate with the indexer crate
match &self.index { match &self.index.backend {
BackendConfig::Tantivy(tantivy) => { BackendConfig::Tantivy(tantivy) => {
Ok(Box::new(TantivyBackend::open(&tantivy.index_dir)?)) Ok(Box::new(TantivyBackend::open(&tantivy.index_dir)?))
} }