File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,10 @@ impl AuthService {
175175 } )
176176 . to_string ( ) ;
177177
178- let mut file = tokio:: fs:: File :: create ( & * self . get_cookie_path ( ) ?)
178+ let cookie_path = & * self . get_cookie_path ( ) ?;
179+ ensure_directory_exists ( cookie_path) ?;
180+
181+ let mut file = tokio:: fs:: File :: create ( cookie_path)
179182 . await
180183 . context ( "Failed to create cookie file" ) ?;
181184 file. write_all ( cookie. as_bytes ( ) )
@@ -227,3 +230,12 @@ async fn wait_for_auth_cookie(page: &Page) -> Result<Cookie> {
227230 tokio:: time:: sleep ( POLL_INTERVAL ) . await ;
228231 }
229232}
233+
234+ fn ensure_directory_exists ( file_path : & str ) -> Result < ( ) > {
235+ if let Some ( parent) = std:: path:: Path :: new ( file_path) . parent ( ) {
236+ std:: fs:: create_dir_all ( parent)
237+ . with_context ( || format ! ( "Failed to create directories for {file_path}" ) ) ?;
238+ }
239+
240+ Ok ( ( ) )
241+ }
You can’t perform that action at this time.
0 commit comments