mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 01:12:24 +00:00
Cleaned update main.rs to the best of my limited knowledge
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -28,18 +28,15 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let config: Config = toml::from_str(&fs::read_to_string(&args.config_file)?)?;
|
let config: Config = toml::from_str(&fs::read_to_string(&args.config_file)?)?;
|
||||||
// TODO: Clean this jank up as soon more configuration options appear
|
|
||||||
let db_path = match config.calendar_store {
|
|
||||||
CalendarStoreConfig::Json(JsonCalendarStoreConfig { db_path }) => db_path,
|
|
||||||
};
|
|
||||||
|
|
||||||
let cal_store = Arc::new(RwLock::new(
|
let cal_store = Arc::new(RwLock::new(match &config.calendar_store {
|
||||||
if let Ok(json) = fs::read_to_string(&db_path) {
|
CalendarStoreConfig::Json(JsonCalendarStoreConfig { db_path }) => {
|
||||||
serde_json::from_str::<JsonCalendarStore>(&json)?
|
match fs::read_to_string(db_path) {
|
||||||
} else {
|
Ok(json) => serde_json::from_str::<JsonCalendarStore>(&json).unwrap(),
|
||||||
JsonCalendarStore::new(db_path.to_string())
|
Err(_) => JsonCalendarStore::new(db_path.to_string()),
|
||||||
},
|
}
|
||||||
));
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
let cal_store = cal_store.clone();
|
let cal_store = cal_store.clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user