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 CB06AD8FA for ; Mon, 17 Jul 2023 10:04:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AC2D9AA4C for ; Mon, 17 Jul 2023 10:04:16 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 for ; Mon, 17 Jul 2023 10:04:16 +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 D316A4276F for ; Mon, 17 Jul 2023 10:04:15 +0200 (CEST) From: Max Carrara To: pbs-devel@lists.proxmox.com Date: Mon, 17 Jul 2023 10:04:09 +0200 Message-Id: <20230717080410.429362-5-m.carrara@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230717080410.429362-1-m.carrara@proxmox.com> References: <20230717080410.429362-1-m.carrara@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.012 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH v3 proxmox-backup 4/5] proxmox-backup-client: restore: add 'ignore-extract-device-errors' flag 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, 17 Jul 2023 08:04:16 -0000 If this flag is provided, any errors that occur during the extraction of a device node are silently ignored. Signed-off-by: Max Carrara --- Changes v1 --> v2: * Remove unnecessary "future-proofing" that merges many error handlers into one Changes v2 --> v3: * Simplify body of `on_error` handler through proper usage of `match` proxmox-backup-client/src/main.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index 1a6114b1..d9e7b899 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -30,6 +30,7 @@ use pbs_api_types::{ BACKUP_TYPE_SCHEMA, TRAFFIC_CONTROL_BURST_SCHEMA, TRAFFIC_CONTROL_RATE_SCHEMA, }; use pbs_client::catalog_shell::Shell; +use pbs_client::pxar::ErrorHandler as PxarErrorHandler; use pbs_client::tools::{ complete_archive_name, complete_auth_id, complete_backup_group, complete_backup_snapshot, complete_backup_source, complete_chunk_size, complete_group_or_snapshot, @@ -1233,6 +1234,12 @@ We do not extract '.pxar' archives when writing to standard output. optional: true, default: false, }, + "ignore-extract-device-errors": { + type: Boolean, + description: "ignore errors that occur during device node extraction", + optional: true, + default: false, + } } } )] @@ -1245,6 +1252,7 @@ async fn restore( ignore_ownership: bool, ignore_permissions: bool, overwrite: bool, + ignore_extract_device_errors: bool, ) -> Result { let repo = extract_repository_from_value(¶m)?; @@ -1365,12 +1373,27 @@ async fn restore( let mut reader = BufferedDynamicReader::new(index, chunk_reader); + let on_error = if ignore_extract_device_errors { + let handler: PxarErrorHandler = Box::new(move |err: Error| { + use pbs_client::pxar::PxarExtractContext; + + match err.downcast_ref::() { + Some(PxarExtractContext::ExtractDevice) => Ok(()), + _ => Err(err), + } + }); + + Some(handler) + } else { + None + }; + let options = pbs_client::pxar::PxarExtractOptions { match_list: &[], extract_match_default: true, allow_existing_dirs, overwrite, - on_error: None, + on_error, }; let mut feature_flags = pbs_client::pxar::Flags::DEFAULT; -- 2.39.2