Skip to content

Commit

Permalink
check if the parent exists for local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhawvipul committed Aug 26, 2024
1 parent 8f08240 commit 767555e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ pub struct LocalStorage {

impl LocalStorage {
pub async fn new(path: String) -> Self {
// Ensure the parent directory exists
if let Some(parent) = Path::new(&path).parent() {
fs::create_dir_all(parent).await.unwrap();
}

let file = OpenOptions::new()
.read(true)
.write(true)
Expand Down

0 comments on commit 767555e

Please sign in to comment.