From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pbs-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
	by lore.proxmox.com (Postfix) with ESMTPS id 1E7141FF38F
	for <inbox@lore.proxmox.com>; Tue, 21 May 2024 14:44:35 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 12875186D1;
	Tue, 21 May 2024 14:44:52 +0200 (CEST)
Message-ID: <d936e2dd-7e0b-4218-bed8-fd439d07bcd1@proxmox.com>
Date: Tue, 21 May 2024 14:44:48 +0200
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird Beta
To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>, Christian Ebner <c.ebner@proxmox.com>
References: <20240514103421.289431-1-c.ebner@proxmox.com>
 <20240514103421.289431-23-c.ebner@proxmox.com>
Content-Language: en-US
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <20240514103421.289431-23-c.ebner@proxmox.com>
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
Subject: Re: [pbs-devel] [PATCH v6 proxmox-backup 22/65] client: restore:
 read payload from dedicated index
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>
Reply-To: Proxmox Backup Server development discussion
 <pbs-devel@lists.proxmox.com>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

this patch (and the next few) introduce a few checks that check the filename
for '.mpxar.didx' or '.mpxar' etc.

wouldn't it be nicer to have a helper that checks that at one point in the code
instead of sprinkling the extension strings around the code?
e.g. a typo at any one of those places is easy to miss but might introduce
bugs or unintended behavior

On 5/14/24 12:33, Christian Ebner wrote:
> Whenever a split pxar archive is encountered, instantiate and attach
> the required dedicated reader instance to the decoder instance on
> restore.
> 
> Piping the output to stdout is not possible for these, as this would
> require a decoder instance which can decode the input stream, while
> maintaining the pxar stream format as output.
> 
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> ---
>   proxmox-backup-client/src/main.rs | 39 ++++++++++++++++++++-----------
>   1 file changed, 25 insertions(+), 14 deletions(-)
> 
> diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
> index b81719dad..821777d66 100644
> --- a/proxmox-backup-client/src/main.rs
> +++ b/proxmox-backup-client/src/main.rs
> @@ -1216,7 +1216,7 @@ async fn dump_image<W: Write>(
>   fn parse_archive_type(name: &str) -> (String, ArchiveType) {
>       if name.ends_with(".didx") || name.ends_with(".fidx") || name.ends_with(".blob") {
>           (name.into(), archive_type(name).unwrap())
> -    } else if name.ends_with(".pxar") {
> +    } else if name.ends_with(".pxar") || name.ends_with(".mpxar") || name.ends_with(".ppxar") {
>           (format!("{}.didx", name), ArchiveType::DynamicIndex)
>       } else if name.ends_with(".img") {
>           (format!("{}.fidx", name), ArchiveType::FixedIndex)
> @@ -1450,20 +1450,15 @@ async fn restore(
>                   .map_err(|err| format_err!("unable to pipe data - {}", err))?;
>           }
>       } else if archive_type == ArchiveType::DynamicIndex {
> -        let index = client
> -            .download_dynamic_index(&manifest, &archive_name)
> -            .await?;
> +        let (archive_name, payload_archive_name) = helper::get_pxar_archive_names(&archive_name);
>   
> -        let most_used = index.find_most_used_chunks(8);
> -
> -        let chunk_reader = RemoteChunkReader::new(
> +        let mut reader = get_buffered_pxar_reader(
> +            &archive_name,
>               client.clone(),
> -            crypt_config,
> -            file_info.chunk_crypt_mode(),
> -            most_used,
> -        );
> -
> -        let mut reader = BufferedDynamicReader::new(index, chunk_reader);
> +            &manifest,
> +            crypt_config.clone(),
> +        )
> +        .await?;
>   
>           let on_error = if ignore_extract_device_errors {
>               let handler: PxarErrorHandler = Box::new(move |err: Error| {
> @@ -1518,8 +1513,21 @@ async fn restore(
>           }
>   
>           if let Some(target) = target {
> +            let decoder = if let Some(payload_archive_name) = payload_archive_name {
> +                let payload_reader = get_buffered_pxar_reader(
> +                    &payload_archive_name,
> +                    client.clone(),
> +                    &manifest,
> +                    crypt_config.clone(),
> +                )
> +                .await?;
> +                pxar::decoder::Decoder::from_std(reader, Some(payload_reader))?
> +            } else {
> +                pxar::decoder::Decoder::from_std(reader, None)?
> +            };
> +
>               pbs_client::pxar::extract_archive(
> -                pxar::decoder::Decoder::from_std(reader, None)?,
> +                decoder,
>                   Path::new(target),
>                   feature_flags,
>                   |path| {
> @@ -1529,6 +1537,9 @@ async fn restore(
>               )
>               .map_err(|err| format_err!("error extracting archive - {:#}", err))?;
>           } else {
> +            if archive_name.ends_with(".mpxar.didx") || archive_name.ends_with(".ppxar.didx") {
> +                bail!("unable to pipe split archive");
> +            }
>               let mut writer = std::fs::OpenOptions::new()
>                   .write(true)
>                   .open("/dev/stdout")



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel