@@ -455,6 +455,9 @@ pub trait Persistence: Clone {
455
455
/// returning the bytes of the file in the success case
456
456
/// and [Self::Err] in the error case
457
457
fn read ( & self , path : & Path ) -> impl Future < Output = Result < Vec < u8 > , Self :: Err > > ;
458
+
459
+ /// recursively ensure that the input path exists
460
+ fn create_dir_all ( & self , path : & Path ) -> impl Future < Output = Result < ( ) , Self :: Err > > ;
458
461
}
459
462
460
463
/// A persistence layer that writes to the local file system
@@ -473,6 +476,11 @@ impl Persistence for FileSystemPersistence {
473
476
let res = std:: fs:: read ( path) ;
474
477
async move { res }
475
478
}
479
+
480
+ fn create_dir_all ( & self , path : & Path ) -> impl Future < Output = Result < ( ) , Self :: Err > > {
481
+ let res = std:: fs:: create_dir_all ( path) ;
482
+ async move { res }
483
+ }
476
484
}
477
485
478
486
impl ImportSource {
@@ -822,6 +830,7 @@ impl<T> StoreInner<T>
822
830
where
823
831
T : Persistence ,
824
832
OuterError : From < T :: Err > ,
833
+ io:: Error : From < T :: Err > ,
825
834
{
826
835
fn new_sync_with_backend (
827
836
path : PathBuf ,
@@ -833,17 +842,17 @@ where
833
842
"creating data directory: {}" ,
834
843
options. path. data_path. display( )
835
844
) ;
836
- std :: fs :: create_dir_all ( & options. path . data_path ) ?;
845
+ rt . block_on ( fs . create_dir_all ( & options. path . data_path ) ) ?;
837
846
tracing:: trace!(
838
847
"creating temp directory: {}" ,
839
848
options. path. temp_path. display( )
840
849
) ;
841
- std :: fs :: create_dir_all ( & options. path . temp_path ) ?;
850
+ rt . block_on ( fs . create_dir_all ( & options. path . temp_path ) ) ?;
842
851
tracing:: trace!(
843
852
"creating parent directory for db file{}" ,
844
853
path. parent( ) . unwrap( ) . display( )
845
854
) ;
846
- std :: fs :: create_dir_all ( path. parent ( ) . unwrap ( ) ) ?;
855
+ rt . block_on ( fs . create_dir_all ( path. parent ( ) . unwrap ( ) ) ) ?;
847
856
let temp: Arc < RwLock < TempCounterMap > > = Default :: default ( ) ;
848
857
let ( actor, tx) = Actor :: new ( & path, options. clone ( ) , temp. clone ( ) , rt. clone ( ) ) ?;
849
858
let handle = std:: thread:: Builder :: new ( )
@@ -1036,7 +1045,7 @@ where
1036
1045
. into ( ) ,
1037
1046
)
1038
1047
} ) ?;
1039
- std :: fs :: create_dir_all ( parent) ?;
1048
+ Handle :: current ( ) . block_on ( self . fs . create_dir_all ( parent) ) ?;
1040
1049
let temp_tag = self . temp . temp_tag ( HashAndFormat :: raw ( hash) ) ;
1041
1050
let ( tx, rx) = oneshot:: channel ( ) ;
1042
1051
self . tx
0 commit comments