File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 11use redb:: { Database , DatabaseError } ;
22use thiserror:: Error ;
3- use std:: { fs, path:: PathBuf , sync:: Arc } ;
3+ use std:: { path:: PathBuf , sync:: Arc } ;
4+ use tokio:: fs;
45
56#[ derive( Clone ) ]
67pub struct DbState {
@@ -22,11 +23,11 @@ pub enum DbSetupError {
2223 Redb ( #[ from] DatabaseError ) ,
2324}
2425
25- pub fn setup_db ( ) -> Result < DbState , DbSetupError > {
26+ pub async fn setup_db ( ) -> Result < DbState , DbSetupError > {
2627 let data_dir = PathBuf :: from ( "data" ) ;
2728
2829 if !data_dir. exists ( ) {
29- fs:: create_dir_all ( & data_dir) ?;
30+ fs:: create_dir_all ( & data_dir) . await ?;
3031 }
3132
3233 let db_path = data_dir. join ( "rk_site.redb" ) ;
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2525 )
2626 } ) ;
2727
28- let db_state = setup_db ( ) . expect ( "Failed to set up Database" ) ;
28+ let db_state = setup_db ( ) . await ? ;
2929
3030 let app = Router :: new ( )
3131 . fallback_service ( frontend_dir) // serve frontend build directory
You can’t perform that action at this time.
0 commit comments