We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ea608b8 commit cba8d46Copy full SHA for cba8d46
1 file changed
src/storage/file.rs
@@ -1,6 +1,6 @@
1
use crate::models::Task;
2
3
-use std::fs::{File, OpenOptions};
+use std::fs::{File, OpenOptions, create_dir_all};
4
use std::io::{BufReader, BufWriter};
5
use std::path::Path;
6
@@ -17,6 +17,12 @@ pub fn load_tasks() -> Vec<Task> {
17
}
18
19
pub fn save_tasks(tasks: &Vec<Task>) {
20
+
21
+ if let Some(parent) = Path::new(DATA_FILE).parent(){
22
+ if !parent.exists(){
23
+ create_dir_all(parent).expect("Failed to create json folder");
24
+ }
25
26
let file = OpenOptions::new()
27
.create(true)
28
.write(true)
0 commit comments