use the existing async method for read_raw_chunk

does the same, except the manual drop, but thats handled there by
letting the value go out of scope

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2020-06-18 13:55:22 +02:00 committed by Dietmar Maurer
parent ba694720fc
commit 16021f6ab7
1 changed files with 1 additions and 15 deletions

View File

@ -50,21 +50,7 @@ impl RemoteChunkReader {
impl ReadChunk for RemoteChunkReader { impl ReadChunk for RemoteChunkReader {
fn read_raw_chunk(&mut self, digest: &[u8; 32]) -> Result<DataBlob, Error> { fn read_raw_chunk(&mut self, digest: &[u8; 32]) -> Result<DataBlob, Error> {
let mut chunk_data = Vec::with_capacity(4 * 1024 * 1024); block_on(Self::read_raw_chunk(self, digest))
//tokio::task::block_in_place(|| futures::executor::block_on(self.client.download_chunk(&digest, &mut chunk_data)))?;
block_on(async {
// download_chunk returns the writer back to us, but we need to return a 'static value
self.client
.download_chunk(&digest, &mut chunk_data)
.await
.map(drop)
})?;
let chunk = DataBlob::from_raw(chunk_data)?;
chunk.verify_crc()?;
Ok(chunk)
} }
fn read_chunk(&mut self, digest: &[u8; 32]) -> Result<Vec<u8>, Error> { fn read_chunk(&mut self, digest: &[u8; 32]) -> Result<Vec<u8>, Error> {