Give error if data_dir exists but is a file.

This commit is contained in:
Nicolás A. Ortega Froysa 2022-07-08 17:24:59 +02:00
parent e62722e397
commit 2149821ebd

View File

@ -78,7 +78,12 @@ fn main()
Err(_e) => PathBuf::from("./"), 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()); println!("Creating {} data directory.", data_dir.display());
fs::create_dir_all(data_dir) fs::create_dir_all(data_dir)