From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 83B0169D33 for ; Mon, 10 Aug 2020 13:25:19 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 80FF01477E for ; Mon, 10 Aug 2020 13:25:19 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1FC3714761 for ; Mon, 10 Aug 2020 13:25:18 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E05C744548 for ; Mon, 10 Aug 2020 13:25:17 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Mon, 10 Aug 2020 13:25:04 +0200 Message-Id: <20200810112509.70129-2-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200810112509.70129-1-f.gruenbichler@proxmox.com> References: <20200810112509.70129-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.047 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup-qemu] adapt to chunk reader changes X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Aug 2020 11:25:19 -0000 for verification of chunk crypt mode <=> index crypt mode match Signed-off-by: Fabian Grünbichler --- follows patch #4 in proxmox-backup src/restore.rs | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/restore.rs b/src/restore.rs index e43d040..9d8c4a2 100644 --- a/src/restore.rs +++ b/src/restore.rs @@ -1,5 +1,4 @@ use std::sync::{Arc, Mutex}; -use std::collections::HashMap; use std::io::SeekFrom; use std::convert::TryInto; @@ -27,7 +26,6 @@ pub(crate) struct RestoreTask { runtime: Arc, crypt_config: Option>, client: OnceCell>, - chunk_reader: OnceCell, manifest: OnceCell>, image_registry: Arc>>, } @@ -59,7 +57,6 @@ impl RestoreTask { crypt_config, client: OnceCell::new(), manifest: OnceCell::new(), - chunk_reader: OnceCell::new(), image_registry: Arc::new(Mutex::new(Registry::::new())), }) } @@ -94,15 +91,6 @@ impl RestoreTask { true ).await?; - let chunk_reader = RemoteChunkReader::new( - client.clone(), - self.crypt_config.clone(), - HashMap::with_capacity(0), - ); - - self.chunk_reader.set(chunk_reader) - .map_err(|_| format_err!("already connected!"))?; - let (manifest, _) = client.download_manifest().await?; self.manifest.set(Arc::new(manifest)) @@ -150,9 +138,12 @@ impl RestoreTask { let most_used = index.find_most_used_chunks(8); + let file_info = manifest.lookup_file_info(&archive_name)?; + let mut chunk_reader = RemoteChunkReader::new( client.clone(), self.crypt_config.clone(), + file_info.chunk_crypt_mode(), most_used, ); @@ -219,11 +210,6 @@ impl RestoreTask { None => bail!("not connected"), }; - let chunk_reader = match self.chunk_reader.get() { - Some(chunk_reader) => chunk_reader.clone(), - None => bail!("not connected"), - }; - let manifest = match self.manifest.get() { Some(manifest) => manifest.clone(), None => bail!("no manifest"), @@ -231,6 +217,16 @@ impl RestoreTask { let index = client.download_fixed_index(&manifest, &archive_name).await?; let archive_size = index.index_bytes(); + let most_used = index.find_most_used_chunks(8); + + let file_info = manifest.lookup_file_info(&archive_name)?; + + let chunk_reader = RemoteChunkReader::new( + client.clone(), + self.crypt_config.clone(), + file_info.chunk_crypt_mode(), + most_used, + ); let reader = AsyncIndexReader::new(index, chunk_reader); -- 2.20.1