From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 4117B1FF2F6 for ; Wed, 15 May 2024 11:55:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F008313C5F; Wed, 15 May 2024 11:55:15 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 15 May 2024 11:55:13 +0200 Message-Id: <20240515095513.1061658-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240515095513.1061658-1-d.csapak@proxmox.com> References: <20240515095513.1061658-1-d.csapak@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [disk.rs] Subject: [pbs-devel] [PATCH proxmox-backup 3/3] restore daemon: search disk also with truncated serial 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: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" the disk serial given to virtio disks only can be 20 characters, so looking for a disk with a longer serial will always fail (like 'drive-tpmstate0-backup'). If the serial is longer, also try with the truncated one. Leave the first try in place in case the limit changes. Signed-off-by: Dominik Csapak --- .../src/proxmox_restore_daemon/disk.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs index db96ced0b..4991479c2 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs @@ -634,12 +634,21 @@ impl DiskState { _ => bail!("no or invalid image in path"), }; - let buckets = match self.disk_map.get_mut( - req_fidx - .strip_suffix(".img.fidx") - .unwrap_or_else(|| req_fidx.as_ref()), - ) { + let serial = req_fidx + .strip_suffix(".img.fidx") + .unwrap_or_else(|| req_fidx.as_ref()); + let buckets = match self.disk_map.get_mut(serial) { Some(x) => x, + None if serial.len() > 20 => { + let (truncated_serial, _) = serial.split_at(20); + eprintln!( + "given image '{req_fidx}' not found with '{serial}', trying with '{truncated_serial}'." + ); + match self.disk_map.get_mut(truncated_serial) { + Some(x) => x, + None => bail!("given image '{req_fidx}' not found with '{truncated_serial}'"), + } + } None => bail!("given image '{req_fidx}' not found"), }; -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel