From 2149821ebdbee8e85aa64cb4b3e7aba2c9a87e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Fri, 8 Jul 2022 17:24:59 +0200 Subject: [PATCH] Give error if data_dir exists but is a file. --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 0a8cdde..4ff0d54 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,7 +78,12 @@ fn main() Err(_e) => PathBuf::from("./"), }; - if !data_dir.exists() + if data_dir.exists() && data_dir.is_file() + { + panic!("Error: {} file already exists! Please (re)move it.", + data_dir.display()); + } + else if !data_dir.exists() { println!("Creating {} data directory.", data_dir.display()); fs::create_dir_all(data_dir)