client: make dump_image async, use async chunk reader

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-06-12 11:40:18 +02:00
parent 4d16badf6f
commit 8e6e18b77c
1 changed files with 4 additions and 4 deletions

View File

@ -39,6 +39,7 @@ use proxmox_backup::backup::{
store_key_config, store_key_config,
verify_chunk_size, verify_chunk_size,
ArchiveType, ArchiveType,
AsyncReadChunk,
BackupDir, BackupDir,
BackupGroup, BackupGroup,
BackupManifest, BackupManifest,
@ -55,7 +56,6 @@ use proxmox_backup::backup::{
IndexFile, IndexFile,
KeyConfig, KeyConfig,
MANIFEST_BLOB_NAME, MANIFEST_BLOB_NAME,
ReadChunk,
Shell, Shell,
}; };
@ -1099,7 +1099,7 @@ fn complete_backup_source(arg: &str, param: &HashMap<String, String>) -> Vec<Str
result result
} }
fn dump_image<W: Write>( async fn dump_image<W: Write>(
client: Arc<BackupReader>, client: Arc<BackupReader>,
crypt_config: Option<Arc<CryptConfig>>, crypt_config: Option<Arc<CryptConfig>>,
index: FixedIndexReader, index: FixedIndexReader,
@ -1119,7 +1119,7 @@ fn dump_image<W: Write>(
for pos in 0..index.index_count() { for pos in 0..index.index_count() {
let digest = index.index_digest(pos).unwrap(); let digest = index.index_digest(pos).unwrap();
let raw_data = chunk_reader.read_chunk(&digest)?; let raw_data = chunk_reader.read_chunk(&digest).await?;
writer.write_all(&raw_data)?; writer.write_all(&raw_data)?;
bytes += raw_data.len(); bytes += raw_data.len();
if verbose { if verbose {
@ -1323,7 +1323,7 @@ async fn restore(param: Value) -> Result<Value, Error> {
.map_err(|err| format_err!("unable to open /dev/stdout - {}", err))? .map_err(|err| format_err!("unable to open /dev/stdout - {}", err))?
}; };
dump_image(client.clone(), crypt_config.clone(), index, &mut writer, verbose)?; dump_image(client.clone(), crypt_config.clone(), index, &mut writer, verbose).await?;
} }
Ok(Value::Null) Ok(Value::Null)