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 14C431FF16E
	for <inbox@lore.proxmox.com>; Mon, 17 Mar 2025 16:11:10 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 028386FDB;
	Mon, 17 Mar 2025 16:11:00 +0100 (CET)
Date: Mon, 17 Mar 2025 16:10:53 +0100
From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion <pbs-devel@lists.proxmox.com>
References: <20250310104318.222927-1-m.sandoval@proxmox.com>
In-Reply-To: <20250310104318.222927-1-m.sandoval@proxmox.com>
MIME-Version: 1.0
User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid)
Message-Id: <1742223904.jjkfbcg6k4.astroid@yuna.none>
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
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 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. [proxmox.com, main.rs]
Subject: [pbs-devel] applied: [PATCH backup] client: allocate two fewer
 strings
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-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pbs-devel-bounces@lists.proxmox.com
Sender: "pbs-devel" <pbs-devel-bounces@lists.proxmox.com>

thanks!

On March 10, 2025 11:43 am, Maximiliano Sandoval wrote:
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> 
> A small improvement I noticed while browsing the project.
> 
>  proxmox-backup-client/src/main.rs | 38 ++++++++++++++-----------------
>  1 file changed, 17 insertions(+), 21 deletions(-)
> 
> diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs
> index 7fa57b2f..5a4dc76f 100644
> --- a/proxmox-backup-client/src/main.rs
> +++ b/proxmox-backup-client/src/main.rs
> @@ -827,40 +827,36 @@ async fn create_backup(
>      let mut target_set = HashSet::new();
>  
>      for backupspec in backupspec_list {
> -        let spec = parse_backup_specification(backupspec.as_str().unwrap())?;
> -        let filename = &spec.config_string;
> -        let target = &spec.archive_name;
> +        let pbs_client::BackupSpecification {
> +            archive_name: target,
> +            config_string: filename,
> +            spec_type,
> +        } = parse_backup_specification(backupspec.as_str().unwrap())?;
>  
> -        if target_set.contains(target) {
> +        if target_set.contains(&target) {
>              bail!("got target twice: '{}'", target);
>          }
> -        target_set.insert(target.to_string());
> +        target_set.insert(target.clone());
>  
>          use std::os::unix::fs::FileTypeExt;
>  
> -        let metadata = std::fs::metadata(filename)
> +        let metadata = std::fs::metadata(&filename)
>              .map_err(|err| format_err!("unable to access '{}' - {}", filename, err))?;
>          let file_type = metadata.file_type();
>  
> -        match spec.spec_type {
> +        match spec_type {
>              BackupSpecificationType::PXAR => {
>                  if !file_type.is_dir() {
>                      bail!("got unexpected file type (expected directory)");
>                  }
> -                upload_list.push((
> -                    BackupSpecificationType::PXAR,
> -                    filename.to_owned(),
> -                    target.to_owned(),
> -                    "didx",
> -                    0,
> -                ));
> +                upload_list.push((BackupSpecificationType::PXAR, filename, target, "didx", 0));
>              }
>              BackupSpecificationType::IMAGE => {
>                  if !(file_type.is_file() || file_type.is_block_device()) {
>                      bail!("got unexpected file type (expected file or block device)");
>                  }
>  
> -                let size = image_size(&PathBuf::from(filename))?;
> +                let size = image_size(&PathBuf::from(&filename))?;
>  
>                  if size == 0 {
>                      bail!("got zero-sized file '{}'", filename);
> @@ -868,8 +864,8 @@ async fn create_backup(
>  
>                  upload_list.push((
>                      BackupSpecificationType::IMAGE,
> -                    filename.to_owned(),
> -                    target.to_owned(),
> +                    filename,
> +                    target,
>                      "fidx",
>                      size,
>                  ));
> @@ -880,8 +876,8 @@ async fn create_backup(
>                  }
>                  upload_list.push((
>                      BackupSpecificationType::CONFIG,
> -                    filename.to_owned(),
> -                    target.to_owned(),
> +                    filename,
> +                    target,
>                      "blob",
>                      metadata.len(),
>                  ));
> @@ -892,8 +888,8 @@ async fn create_backup(
>                  }
>                  upload_list.push((
>                      BackupSpecificationType::LOGFILE,
> -                    filename.to_owned(),
> -                    target.to_owned(),
> +                    filename,
> +                    target,
>                      "blob",
>                      metadata.len(),
>                  ));
> -- 
> 2.39.5
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 


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