@@ -101,7 +101,7 @@ impl<'a> Storage<'a> {
101
101
let trans = conn. transaction ( ) ?;
102
102
let mut file_paths_and_mimes = HashMap :: new ( ) ;
103
103
104
- get_file_list ( root_dir) ?
104
+ let mut blobs = get_file_list ( root_dir) ?
105
105
. into_iter ( )
106
106
. filter_map ( |file_path| {
107
107
// Some files have insufficient permissions
@@ -111,7 +111,7 @@ impl<'a> Storage<'a> {
111
111
. ok ( )
112
112
. map ( |file| ( file_path, file) )
113
113
} )
114
- . map ( |( file_path, mut file) | {
114
+ . map ( |( file_path, mut file) | -> Result < _ , Error > {
115
115
let mut content: Vec < u8 > = Vec :: new ( ) ;
116
116
file. read_to_end ( & mut content) ?;
117
117
@@ -132,10 +132,17 @@ impl<'a> Storage<'a> {
132
132
// this field is ignored by the backend
133
133
date_updated : Timespec :: new ( 0 , 0 ) ,
134
134
} )
135
- } )
136
- . collect :: < Result < Vec < _ > , Error > > ( ) ?
137
- . chunks ( MAX_CONCURRENT_UPLOADS )
138
- . try_for_each ( |batch| self . store_batch ( batch, & trans) ) ?;
135
+ } ) ;
136
+ loop {
137
+ let batch: Vec < _ > = blobs
138
+ . by_ref ( )
139
+ . take ( MAX_CONCURRENT_UPLOADS )
140
+ . collect :: < Result < _ , Error > > ( ) ?;
141
+ if batch. is_empty ( ) {
142
+ break ;
143
+ }
144
+ self . store_batch ( & batch, & trans) ?;
145
+ }
139
146
140
147
trans. commit ( ) ?;
141
148
Ok ( file_paths_and_mimes)
0 commit comments