1
0
mirror of https://github.com/actix/examples synced 2024-11-24 06:43:00 +01:00

multipart: fix size result calculation

This commit is contained in:
Sylvain Kerkour 2019-04-22 15:10:25 +02:00 committed by Douman
parent f073d9029f
commit 982ec7bb2f

View File

@ -23,13 +23,12 @@ pub fn save_file(field: Field) -> impl Future<Item = i64, Error = Error> {
// fs operations are blocking, we have to execute writes // fs operations are blocking, we have to execute writes
// on threadpool // on threadpool
web::block(move || { web::block(move || {
acc += file file.write_all(bytes.as_ref())
.write_all(bytes.as_ref())
.map(|_| acc + bytes.len() as i64)
.map_err(|e| { .map_err(|e| {
println!("file.write_all failed: {:?}", e); println!("file.write_all failed: {:?}", e);
MultipartError::Payload(error::PayloadError::Io(e)) MultipartError::Payload(error::PayloadError::Io(e))
})?; })?;
acc += bytes.len() as i64;
Ok((file, acc)) Ok((file, acc))
}) })
.map_err(|e: error::BlockingError<MultipartError>| { .map_err(|e: error::BlockingError<MultipartError>| {