mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 07:02:24 +00:00
Remove toml store
This commit is contained in:
@@ -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),
|
||||
}
|
||||
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user