Skip to content

Commit 767555e

Browse files
committed
check if the parent exists for local storage
1 parent 8f08240 commit 767555e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/storage.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ pub struct LocalStorage {
3636

3737
impl LocalStorage {
3838
pub async fn new(path: String) -> Self {
39+
// Ensure the parent directory exists
40+
if let Some(parent) = Path::new(&path).parent() {
41+
fs::create_dir_all(parent).await.unwrap();
42+
}
43+
3944
let file = OpenOptions::new()
4045
.read(true)
4146
.write(true)

0 commit comments

Comments
 (0)