From 767555e1e71b004bf77e755df89976fe04692686 Mon Sep 17 00:00:00 2001 From: Vipul Vaibhaw Date: Mon, 26 Aug 2024 11:19:30 +0530 Subject: [PATCH] check if the parent exists for local storage --- src/storage.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/storage.rs b/src/storage.rs index d9ccca2..5197fec 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -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)