From d3d61f660297cf24b2bb17b9c177671db35c012e Mon Sep 17 00:00:00 2001 From: Neshura Date: Sun, 17 Dec 2023 20:17:00 +0100 Subject: [PATCH] Small QOL changes --- src/config/mod.rs | 2 +- src/post_history/mod.rs | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/config/mod.rs b/src/config/mod.rs index 09fe1e6..0a9604e 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -55,7 +55,7 @@ pub(crate) struct SeriesConfig { #[derive(Debug, Serialize, Deserialize, Clone)] pub(crate) struct PostConfig { - pub(crate) community_name: String, + pub(crate) name: String, pub(crate) pin_settings: PinConfig, pub(crate) post_body: PostBody, } diff --git a/src/post_history/mod.rs b/src/post_history/mod.rs index 5d30a9f..7d685e1 100644 --- a/src/post_history/mod.rs +++ b/src/post_history/mod.rs @@ -6,29 +6,33 @@ use std::io::Write; use std::path::Path; use serde_derive::{Deserialize, Serialize}; -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize, Deserialize, Clone, Debug)] pub(crate) struct SeriesHistory { pub(crate) series: HashMap, } impl SeriesHistory { - pub(crate) fn load_history() -> Result, Box> { + pub(crate) fn load_history() -> Result> { match Path::new("history.toml").exists() { true => { let file_contents: String = fs::read_to_string("history.toml")?; let history: Result = match file_contents.len() { - 0 => return Ok(None), + 0 => return Ok(SeriesHistory { + series: HashMap::new(), + }), _ => toml::from_str(file_contents.as_str()), }; match history { - Ok(data) => Ok(Some(data)), + Ok(data) => Ok(data), Err(e) => Err(Box::new(e)) } }, false => { - Ok(None) + Ok(SeriesHistory { + series: HashMap::new(), + }) } } } @@ -72,9 +76,9 @@ impl SeriesHistory { } } -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize, Deserialize, Clone, Debug)] pub(crate) struct PostHistory { - parts: HashMap, + pub(crate) parts: HashMap, } impl PostHistory { @@ -96,7 +100,7 @@ impl PostHistory { } } -#[derive(Serialize, Deserialize, Clone)] +#[derive(Serialize, Deserialize, Clone, Debug)] pub(crate) struct PostHistoryInner { pub(crate) volume: String, pub(crate) chapter: String,