Create data directory if not exists

main
Elnu 2 years ago
parent 1dfa68452b
commit ab30279375

@ -67,6 +67,10 @@ pub fn get_submission_data(challenge: i32) -> Vec<Value> {
json
}
Err(ref e) if e.kind() == std::io::ErrorKind::NotFound => {
// Create parent directory if not exists
if let Some(parent_dir) = std::path::Path::new(&submission_data_path).parent() {
fs::create_dir_all(parent_dir).unwrap();
}
let mut file = File::create(&submission_data_path).unwrap();
file.write_all(b"[]").unwrap();
file.flush().unwrap();

Loading…
Cancel
Save