From e86078e889048fa70b755e993483258ddfa41ee7 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 24 Mar 2024 12:22:00 -0400 Subject: [PATCH] add some comments and check if tmp/ exists and create it if not --- counter.numb | 1 + src/main.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 counter.numb diff --git a/counter.numb b/counter.numb new file mode 100644 index 0000000..c227083 --- /dev/null +++ b/counter.numb @@ -0,0 +1 @@ +0 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 30963c5..542735c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,11 @@ +// hit-counter-rs +// it's a hit counter, but in rust. I am also very new to rust, ごめん +// // Due to the slowness of imagemagick (and calling system commands and w/e else) // the image that the user will see on the page will be -1 behind the actual count +// +// todo: +// all files are relative to working directory -> specifiy via cli and/or some config file use actix_web::{ get, App, @@ -19,6 +25,7 @@ const MONTAGE_PATH: &str = "/bin/montage"; //const MONTAGE_ARGS: &str = "-tile 6x1 -geometry +0+0 -background none -scale 50"; const ASSET_DIR: &str = "asset/"; const TMP_OUTPUT: &str = "tmp/counter.png"; +const TMP_DIR: &str = "tmp"; const BIND_IP: &str = "127.0.0.1"; @@ -104,6 +111,9 @@ async fn main() -> std::io::Result<()> { unsafe { read_counter(); } + if !std::path::Path::new(TMP_DIR).exists() { + std::fs::create_dir(TMP_DIR)?; + } log::info!("starting HTTP server at http://{BIND_IP}:{BIND_PORT}");