@@ -153,6 +153,8 @@ pub fn add_path_into_database<P: AsRef<Path>>(conn: &Connection,
153
153
use std:: collections:: HashMap ;
154
154
let mut file_paths_and_mimes: HashMap < PathBuf , String > = HashMap :: new ( ) ;
155
155
156
+ use futures:: future:: Future ;
157
+
156
158
let mut rt = :: tokio:: runtime:: Runtime :: new ( ) . unwrap ( ) ;
157
159
158
160
let mut to_upload = try!( get_file_list ( & path) ) ;
@@ -205,6 +207,8 @@ pub fn add_path_into_database<P: AsRef<Path>>(conn: &Connection,
205
207
body : Some ( content. clone ( ) . into ( ) ) ,
206
208
content_type : Some ( mime. clone ( ) ) ,
207
209
..Default :: default ( )
210
+ } ) . inspect ( |_| {
211
+ crate :: web:: metrics:: UPLOADED_FILES_TOTAL . inc_by ( 1 ) ;
208
212
} ) ) ;
209
213
} else {
210
214
// If AWS credentials are configured, don't insert/update the database
@@ -229,7 +233,6 @@ pub fn add_path_into_database<P: AsRef<Path>>(conn: &Connection,
229
233
230
234
if rt. block_on ( :: futures:: future:: join_all ( futures) ) . is_ok ( ) {
231
235
// this batch was successful, start another batch if there are still more files
232
- crate :: web:: metrics:: UPLOADED_FILES_TOTAL . inc_by ( batch_size as i64 ) ;
233
236
batch_size = cmp:: min ( to_upload. len ( ) , MAX_CONCURRENT_UPLOADS ) ;
234
237
currently_uploading = to_upload. drain ( ..batch_size) . collect ( ) ;
235
238
attempts = 0 ;
@@ -240,7 +243,6 @@ pub fn add_path_into_database<P: AsRef<Path>>(conn: &Connection,
240
243
}
241
244
}
242
245
} else {
243
- crate :: web:: metrics:: UPLOADED_FILES_TOTAL . inc_by ( batch_size as i64 ) ;
244
246
batch_size = cmp:: min ( to_upload. len ( ) , MAX_CONCURRENT_UPLOADS ) ;
245
247
currently_uploading = to_upload. drain ( ..batch_size) . collect ( ) ;
246
248
}
0 commit comments