diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index e0af010..0bba960 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,10 +4,12 @@ pub mod worker_ws; use anyhow::Result; use axum::{Router, routing::get}; +use log::{debug, info}; use serde_json::{Map, Value}; use std::{ collections::{HashMap, HashSet}, sync::Arc, + time::Instant, }; use tokio::{ fs::{File, read_to_string, rename}, @@ -54,12 +56,16 @@ async fn main() -> Result<()> { impl State { pub async fn load(&mut self) -> Result<()> { + debug!("loading state"); + let t = Instant::now(); self.metadata = serde_json::from_str(&read_to_string("metadata.json").await?)?; self.queue = serde_json::from_str(&read_to_string("queue.json").await?)?; self.complete = serde_json::from_str(&read_to_string("complete.json").await?)?; + info!("state loaded (took {:?})", t.elapsed()); Ok(()) } pub async fn save(&mut self) -> Result<()> { + let t = Instant::now(); File::create("metadata.json~") .await? .write_all(&serde_json::to_vec(&self.metadata)?) @@ -76,7 +82,7 @@ impl State { rename("metadata.json~", "metadata.json").await?; rename("queue.json~", "queue.json").await?; rename("complete.json~", "complete.json").await?; - + info!("state saved (took {:?})", t.elapsed()); Ok(()) } } |