Remove toml store

This commit is contained in:
Lennart
2024-06-21 18:01:41 +02:00
parent 0994c484d1
commit 9c703673fa
4 changed files with 1 additions and 126 deletions

View File

@@ -7,11 +7,6 @@ pub struct HttpConfig {
pub port: u16,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct TomlCalendarStoreConfig {
pub db_path: String,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct SqliteCalendarStoreConfig {
pub db_url: String,
@@ -20,7 +15,6 @@ pub struct SqliteCalendarStoreConfig {
#[derive(Debug, Deserialize, Serialize)]
#[serde(tag = "backend", rename_all = "snake_case")]
pub enum CalendarStoreConfig {
Toml(TomlCalendarStoreConfig),
Sqlite(SqliteCalendarStoreConfig),
}

View File

@@ -3,10 +3,9 @@ use actix_web::HttpServer;
use anyhow::Result;
use app::make_app;
use clap::Parser;
use config::{CalendarStoreConfig, SqliteCalendarStoreConfig, TomlCalendarStoreConfig};
use config::{CalendarStoreConfig, SqliteCalendarStoreConfig};
use rustical_auth::AuthProvider;
use rustical_store::sqlite_store::{create_db_pool, SqliteCalendarStore};
use rustical_store::toml_store::TomlCalendarStore;
use rustical_store::CalendarStore;
use std::fs;
use std::sync::Arc;
@@ -29,12 +28,6 @@ async fn get_cal_store(
config: &CalendarStoreConfig,
) -> Result<Arc<RwLock<dyn CalendarStore>>> {
let cal_store: Arc<RwLock<dyn CalendarStore>> = match &config {
CalendarStoreConfig::Toml(TomlCalendarStoreConfig { db_path }) => {
Arc::new(RwLock::new(match fs::read_to_string(db_path) {
Ok(content) => toml::from_str::<TomlCalendarStore>(&content).unwrap(),
Err(_) => TomlCalendarStore::new(db_path.to_string()),
}))
}
CalendarStoreConfig::Sqlite(SqliteCalendarStoreConfig { db_url }) => {
let db = create_db_pool(db_url, migrate).await?;
Arc::new(RwLock::new(SqliteCalendarStore::new(db)))