src/api2/admin/datastore.rs: switch to async
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
5c1130df9f
commit
6be147b78c
|
@ -485,12 +485,12 @@ fn download_file(
|
||||||
let response_future = tokio::fs::File::open(path)
|
let response_future = tokio::fs::File::open(path)
|
||||||
.map_err(|err| http_err!(BAD_REQUEST, format!("File open failed: {}", err)))
|
.map_err(|err| http_err!(BAD_REQUEST, format!("File open failed: {}", err)))
|
||||||
.and_then(move |file| {
|
.and_then(move |file| {
|
||||||
let payload = tokio::codec::FramedRead::new(file, tokio::codec::BytesCodec::new()).
|
let payload = tokio::codec::FramedRead::new(file, tokio::codec::BytesCodec::new())
|
||||||
map(|bytes| hyper::Chunk::from(bytes.freeze()));
|
.map_ok(|bytes| hyper::Chunk::from(bytes.freeze()));
|
||||||
let body = Body::wrap_stream(payload);
|
let body = Body::wrap_stream(payload);
|
||||||
|
|
||||||
// fixme: set other headers ?
|
// fixme: set other headers ?
|
||||||
Ok(Response::builder()
|
futures::future::ok(Response::builder()
|
||||||
.status(StatusCode::OK)
|
.status(StatusCode::OK)
|
||||||
.header(header::CONTENT_TYPE, "application/octet-stream")
|
.header(header::CONTENT_TYPE, "application/octet-stream")
|
||||||
.body(body)
|
.body(body)
|
||||||
|
@ -545,11 +545,11 @@ fn upload_backup_log(
|
||||||
|
|
||||||
let resp = req_body
|
let resp = req_body
|
||||||
.map_err(Error::from)
|
.map_err(Error::from)
|
||||||
.fold(Vec::new(), |mut acc, chunk| {
|
.try_fold(Vec::new(), |mut acc, chunk| {
|
||||||
acc.extend_from_slice(&*chunk);
|
acc.extend_from_slice(&*chunk);
|
||||||
Ok::<_, Error>(acc)
|
future::ok::<_, Error>(acc)
|
||||||
})
|
})
|
||||||
.and_then(move |data| {
|
.and_then(move |data| async move {
|
||||||
let blob = DataBlob::from_raw(data)?;
|
let blob = DataBlob::from_raw(data)?;
|
||||||
// always verify CRC at server side
|
// always verify CRC at server side
|
||||||
blob.verify_crc()?;
|
blob.verify_crc()?;
|
||||||
|
@ -558,7 +558,7 @@ fn upload_backup_log(
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.and_then(move |_| {
|
.and_then(move |_| {
|
||||||
Ok(crate::server::formatter::json_response(Ok(Value::Null)))
|
future::ok(crate::server::formatter::json_response(Ok(Value::Null)))
|
||||||
})
|
})
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue