add AsyncReaderStream

and replace AsyncIndexReader's stream implementation with that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2020-06-22 16:44:13 +02:00
committed by Dietmar Maurer
parent 3ddb14889a
commit f386f512d0
3 changed files with 45 additions and 64 deletions

View File

@ -23,7 +23,7 @@ use crate::config::datastore;
use crate::config::cached_user_info::CachedUserInfo;
use crate::server::WorkerTask;
use crate::tools::{self, WrappedReaderStream};
use crate::tools::{self, AsyncReaderStream, WrappedReaderStream};
use crate::config::acl::{
PRIV_DATASTORE_AUDIT,
PRIV_DATASTORE_MODIFY,
@ -842,7 +842,7 @@ fn download_file_decoded(
let chunk_reader = LocalChunkReader::new(datastore, None);
let reader = AsyncIndexReader::new(index, chunk_reader);
Body::wrap_stream(reader
Body::wrap_stream(AsyncReaderStream::new(reader)
.map_err(move |err| {
eprintln!("error during streaming of '{:?}' - {}", path, err);
err
@ -854,7 +854,7 @@ fn download_file_decoded(
let chunk_reader = LocalChunkReader::new(datastore, None);
let reader = AsyncIndexReader::new(index, chunk_reader);
Body::wrap_stream(reader
Body::wrap_stream(AsyncReaderStream::with_buffer_size(reader, 4*1024*1024)
.map_err(move |err| {
eprintln!("error during streaming of '{:?}' - {}", path, err);
err