From: Thomas Lamprecht Date: Sat, 30 May 2020 16:42:17 +0000 (+0200) Subject: restore: reuse the clients download_fixed_index X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=564910b0806d132982606f7b360adb35bd25d1ba;p=proxmox-backup-qemu.git restore: reuse the clients download_fixed_index it's the same code Signed-off-by: Thomas Lamprecht --- diff --git a/src/restore.rs b/src/restore.rs index 345a3a6..ed74862 100644 --- a/src/restore.rs +++ b/src/restore.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, format_err, Error}; +use anyhow::{bail, Error}; use std::sync::Arc; use std::os::unix::fs::OpenOptionsExt; @@ -92,20 +92,10 @@ impl ProxmoxRestore { verbose: bool, ) -> Result<(), Error> { - let tmpfile = std::fs::OpenOptions::new() - .write(true) - .read(true) - .custom_flags(libc::O_TMPFILE) - .open("/tmp")?; - - let tmpfile = self.client.download(&archive_name, tmpfile).await?; - - let index = FixedIndexReader::new(tmpfile) - .map_err(|err| format_err!("unable to read fixed index '{}' - {}", archive_name, err))?; - - // Note: do not use values stored in index (not trusted) - instead, computed them again - let (csum, size) = index.compute_csum(); - self.manifest.verify_file(&archive_name, &csum, size)?; + if verbose { + eprintln!("download and verify backup index"); + } + let index = self.client.download_fixed_index(&self.manifest, &archive_name).await?; let (_, zero_chunk_digest) = DataChunkBuilder::build_zero_chunk( self.crypt_config.as_ref().map(Arc::as_ref),