From fd228be9161848c9339df9e6787e1bd8944edf5b Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 24 Apr 2023 17:34:58 +0200 Subject: [PATCH] don't crash if blog folder doesnt exist --- src/routes/blog.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/routes/blog.rs b/src/routes/blog.rs index 72c013c..ff1acfc 100644 --- a/src/routes/blog.rs +++ b/src/routes/blog.rs @@ -52,11 +52,13 @@ struct Post { } fn get_posts(location: &str) -> Vec { - let entries = std::fs::read_dir(location) - .unwrap() - .flatten() - .filter(|f| f.path().extension().unwrap() == "md") - .collect::>(); + let entries = match std::fs::read_dir(location) { + Ok(res) => res + .flatten() + .filter(|f| f.path().extension().unwrap() == "md") + .collect::>(), + Err(_) => vec![], + }; entries .iter()