From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id F09291FF13F for ; Thu, 26 Feb 2026 15:40:56 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 45CE834259; Thu, 26 Feb 2026 15:41:55 +0100 (CET) From: Robert Obkircher To: pbs-devel@lists.proxmox.com Subject: [PATCH v1 proxmox-backup 09/11] client: catalog shell: combine multiple block_on calls into one Date: Thu, 26 Feb 2026 15:40:23 +0100 Message-ID: <20260226144033.211039-10-r.obkircher@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260226144033.211039-1-r.obkircher@proxmox.com> References: <20260226144033.211039-1-r.obkircher@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1772116858037 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.057 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 Message-ID-Hash: JWYKI4U6T4K24TLYO5CGVLHL6QSSVISP X-Message-ID-Hash: JWYKI4U6T4K24TLYO5CGVLHL6QSSVISP X-MailFrom: r.obkircher@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Reduce the number of places where block_on is called. Signed-off-by: Robert Obkircher --- pbs-client/src/catalog_shell.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pbs-client/src/catalog_shell.rs b/pbs-client/src/catalog_shell.rs index 43f0a73b..5e62a62a 100644 --- a/pbs-client/src/catalog_shell.rs +++ b/pbs-client/src/catalog_shell.rs @@ -104,7 +104,7 @@ pub fn catalog_shell_cli() -> CommandLineInterface { fn complete_path(complete_me: &str, _map: &HashMap) -> Vec { let shell: &mut Shell = unsafe { std::mem::transmute(SHELL.unwrap()) }; - match shell.complete_path(complete_me) { + match block_on(shell.complete_path(complete_me)) { Ok(list) => list, Err(err) => { error!("error during completion: {}", err); @@ -554,7 +554,7 @@ impl Shell { Ok(()) } - fn step_nofollow( + async fn step_nofollow( stack: &mut Vec, catalog: &mut Option, component: std::path::Component<'_>, @@ -579,8 +579,8 @@ impl Shell { } } else { let pxar_entry = parent_pxar_entry(stack)?; - let parent_dir = block_on(pxar_entry.enter_directory())?; - match block_on(parent_dir.lookup(entry))? { + let parent_dir = pxar_entry.enter_directory().await?; + match parent_dir.lookup(entry).await? { Some(entry) => { let entry_attr = DirEntryAttribute::try_from(&entry)?; stack.push(PathStackEntry { @@ -614,13 +614,13 @@ impl Shell { } /// Non-async version cannot follow symlinks. - fn walk_catalog_nofollow( + async fn walk_catalog_nofollow( stack: &mut Vec, catalog: &mut Option, path: &Path, ) -> Result<(), Error> { for c in path.components() { - Self::step_nofollow(stack, catalog, c)?; + Self::step_nofollow(stack, catalog, c).await?; } Ok(()) } @@ -657,7 +657,7 @@ impl Shell { Ok(stack.last().unwrap().pxar.clone().unwrap()) } - fn complete_path(&mut self, input: &str) -> Result, Error> { + async fn complete_path(&mut self, input: &str) -> Result, Error> { let mut tmp_stack; let (parent, base, part) = match input.rfind('/') { Some(ind) => { @@ -668,7 +668,7 @@ impl Shell { } else { tmp_stack = self.position.clone(); } - Self::walk_catalog_nofollow(&mut tmp_stack, &mut self.catalog, &path)?; + Self::walk_catalog_nofollow(&mut tmp_stack, &mut self.catalog, &path).await?; (&tmp_stack.last().unwrap(), base, part) } None => (&self.position.last().unwrap(), "", input), @@ -678,12 +678,12 @@ impl Shell { catalog.read_dir(&parent.catalog)? } else { let dir = if let Some(entry) = parent.pxar.as_ref() { - block_on(entry.enter_directory())? + entry.enter_directory().await? } else { bail!("missing pxar entry for parent"); }; let mut out = Vec::new(); - let entries = block_on(crate::pxar::tools::pxar_metadata_read_dir(dir))?; + let entries = crate::pxar::tools::pxar_metadata_read_dir(dir).await?; for entry in entries { let mut name = base.to_string(); let file_name = entry.file_name().as_bytes(); -- 2.47.3