Create data directory if not exists
This commit is contained in:
parent
1dfa68452b
commit
ab30279375
1 changed files with 4 additions and 0 deletions
|
@ -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…
Add table
Reference in a new issue