From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <m.carrara@proxmox.com>
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 A2F3BD22E
 for <pbs-devel@lists.proxmox.com>; Thu, 13 Jul 2023 10:07:16 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 852F03693E
 for <pbs-devel@lists.proxmox.com>; Thu, 13 Jul 2023 10:06:46 +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 <pbs-devel@lists.proxmox.com>; Thu, 13 Jul 2023 10:06:45 +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 C8D41415DF
 for <pbs-devel@lists.proxmox.com>; Thu, 13 Jul 2023 10:06:44 +0200 (CEST)
Message-ID: <0328e431-77e0-db44-c2df-8d75ff602dad@proxmox.com>
Date: Thu, 13 Jul 2023 10:06:43 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Content-Language: en-US
To: Christoph Heiss <c.heiss@proxmox.com>,
 Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com>
References: <20230712130044.1611784-1-m.carrara@proxmox.com>
 <20230712130044.1611784-5-m.carrara@proxmox.com>
 <dimadx7gnlknk7u7cqpqlloat5zzkwdoidwbyjys4z5r4rydtz@tlm3x6m4vwyn>
From: Max Carrara <m.carrara@proxmox.com>
In-Reply-To: <dimadx7gnlknk7u7cqpqlloat5zzkwdoidwbyjys4z5r4rydtz@tlm3x6m4vwyn>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.044 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
 NICE_REPLY_A            -0.11 Looks like a legit reply (A)
 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: Re: [pbs-devel] [PATCH v2 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
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 13 Jul 2023 08:07:16 -0000

On 7/13/23 09:52, Christoph Heiss wrote:
> 
> On Wed, Jul 12, 2023 at 03:00:43PM +0200, Max Carrara wrote:
>> If this flag is provided, any errors that occur during the extraction
>> of a device node are silently ignored.
>>
>> Signed-off-by: Max Carrara <m.carrara@proxmox.com>
>> ---
>>  Changes v1 --> v2:
>>   * Remove unnecessary "future-proofing" that merges many error handlers into one
>>
>>  proxmox-backup-client/src/main.rs | 32 ++++++++++++++++++++++++++++++-
>>  1 file changed, 31 insertions(+), 1 deletion(-)
>>
>> diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
>> index 1a6114b1..c7f90109 100644
>> --- a/proxmox-backup-client/src/main.rs
>> +++ b/proxmox-backup-client/src/main.rs
>>
>> [..]
>>
>> @@ -1245,6 +1252,7 @@ async fn restore(
>>      ignore_ownership: bool,
>>      ignore_permissions: bool,
>>      overwrite: bool,
>> +    ignore_extract_device_errors: bool,
>>  ) -> Result<Value, Error> {
>>      let repo = extract_repository_from_value(&param)?;
>>
>> @@ -1365,12 +1373,34 @@ 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;
>> +
>> +                let ctx = err.downcast_ref::<PxarExtractContext>();
>> +
>> +                if ctx.is_none() {
>> +                    return Err(err);
>> +                }
>> +
>> +                if matches!(ctx.unwrap(), PxarExtractContext::ExtractDevice) {
>> +                    return Ok(());
>> +                }
>> +
>> +                Err(err)
>> +            });
>> +
>> +            Some(handler)
> Couldn't this be a lot simpler written as:
> 
> Some(Box::new(move |err: Error| {
>     use pbs_client::pxar::PxarExtractContext;
> 
>     match err.downcast_ref::<PxarExtractContext>() {
> 	Some(PxarExtractContext::ExtractDevice) => Ok(()),
> 	_ => Err(err),
>     }
> }))
> 
> (untested; just off the top of my head)
> 

Oh, true! I missed that one. I'll see what else turns up before
sending in another series though.

>> +        } 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
>>
>>
>>
>> _______________________________________________
>> pbs-devel mailing list
>> pbs-devel@lists.proxmox.com
>> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>>
>>