]> git.proxmox.com Git - proxmox-backup.git/commitdiff
src/client/remote_chunk_reader.rs: pass reference to download_chunk
authorDietmar Maurer <dietmar@proxmox.com>
Sat, 5 Oct 2019 09:45:20 +0000 (11:45 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Sat, 5 Oct 2019 09:45:20 +0000 (11:45 +0200)
Make sure we do not move data around.

src/client/remote_chunk_reader.rs

index 7fd700cfa8d65bcd2807585a62c19d1008d59313..f56e93c4f9c46efd962fed489472f05128438985 100644 (file)
@@ -33,7 +33,7 @@ impl ReadChunk for RemoteChunkReader {
 
     fn read_chunk(&mut self, digest:&[u8; 32]) -> Result<Vec<u8>, Error> {
 
-        let writer = Vec::with_capacity(4*1024*1024);
+        let mut chunk_data = Vec::with_capacity(4*1024*1024);
 
         if let Some(raw_data) = self.cache.get(digest) {
             return Ok(raw_data.to_vec());
@@ -41,7 +41,7 @@ impl ReadChunk for RemoteChunkReader {
 
         let use_cache = self.cache_hint.contains_key(digest);
 
-        let chunk_data = futures::executor::block_on(self.client.download_chunk(&digest, writer))?;
+        futures::executor::block_on(self.client.download_chunk(&digest, &mut chunk_data))?;
 
         let chunk = DataChunk::from_raw(chunk_data, *digest)?;
         chunk.verify_crc()?;