@@ -59,8 +59,7 @@ pub mod tokio {
5959 if !meta. is_file ( ) {
6060 return None ;
6161 }
62- let result = tokio:: fs:: read ( path) . await . unwrap ( ) ;
63- Some ( result)
62+ tokio:: fs:: read ( path) . await . ok ( )
6463 }
6564 }
6665
@@ -81,8 +80,15 @@ pub mod tokio {
8180 // Now walk the directory, recursively
8281 let mut to_visit = vec ! [ ( path, prefix) ] ;
8382 while let Some ( ( next_path, key_prefix) ) = to_visit. pop ( ) {
84- let mut entries = tokio:: fs:: read_dir ( & next_path) . await . unwrap ( ) ;
85- while let Some ( entry) = entries. next_entry ( ) . await . unwrap ( ) {
83+ let Ok ( mut entries) = tokio:: fs:: read_dir ( & next_path) . await else {
84+ continue ;
85+ } ;
86+ loop {
87+ let entry = match entries. next_entry ( ) . await {
88+ Ok ( Some ( entry) ) => entry,
89+ Ok ( None ) => break ,
90+ Err ( _) => break ,
91+ } ;
8692 let Some ( filename) = entry. file_name ( ) . to_str ( ) . map ( |s| s. to_string ( ) )
8793 else {
8894 continue ; // Skip entries with non-UTF8 names
@@ -96,8 +102,10 @@ pub mod tokio {
96102 } ;
97103 if entry_meta. is_dir ( ) {
98104 to_visit. push ( ( entry_path, next_key_prefix) ) ;
99- } else if entry_path. is_file ( ) {
100- let data = tokio:: fs:: read ( & entry_path) . await . unwrap ( ) ;
105+ } else if entry_meta. is_file ( ) {
106+ let Ok ( data) = tokio:: fs:: read ( & entry_path) . await else {
107+ continue ;
108+ } ;
101109 result. insert ( next_key_prefix, data) ;
102110 }
103111 }
@@ -113,16 +121,18 @@ pub mod tokio {
113121 ) -> impl Future < Output = ( ) > + Send {
114122 let path = self . key_to_path ( & key) ;
115123 async move {
116- let parent = path. parent ( ) . unwrap ( ) ;
117- tokio:: fs:: create_dir_all ( parent) . await . unwrap ( ) ;
118- tokio:: fs:: write ( path, data) . await . unwrap ( ) ;
124+ if let Some ( parent) = path. parent ( )
125+ && tokio:: fs:: create_dir_all ( parent) . await . is_err ( ) {
126+ return ;
127+ }
128+ let _ = tokio:: fs:: write ( path, data) . await ;
119129 }
120130 }
121131
122132 fn delete ( & self , key : samod_core:: StorageKey ) -> impl Future < Output = ( ) > + Send {
123133 let path = self . key_to_path ( & key) ;
124134 async move {
125- tokio:: fs:: remove_file ( path) . await . unwrap ( ) ;
135+ let _ = tokio:: fs:: remove_file ( path) . await ;
126136 }
127137 }
128138 }
0 commit comments