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 6F46395009 for ; Tue, 28 Feb 2023 10:41:25 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3C7F353DB for ; Tue, 28 Feb 2023 10:41:25 +0100 (CET) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 28 Feb 2023 10:41:24 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BB88948A26 for ; Tue, 28 Feb 2023 10:41:23 +0100 (CET) Date: Tue, 28 Feb 2023 10:41:22 +0100 From: Wolfgang Bumiller To: Hannes Laimer Cc: pbs-devel@lists.proxmox.com Message-ID: <20230228094122.wkjchjyqlsf5u5kb@casey.proxmox.com> References: <20230223125540.1298442-1-h.laimer@proxmox.com> <20230223125540.1298442-2-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230223125540.1298442-2-h.laimer@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.184 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [sync.rs, pull.rs, jobs.rs, remote.rs, tasks.rs] Subject: Re: [pbs-devel] [PATCH proxmox-backup v2 1/5] api2: make Remote for SyncJob optional 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: Tue, 28 Feb 2023 09:41:25 -0000 Just minor things. On Thu, Feb 23, 2023 at 01:55:36PM +0100, Hannes Laimer wrote: > Signed-off-by: Hannes Laimer > --- > pbs-api-types/src/jobs.rs | 4 +- > src/api2/config/remote.rs | 2 +- > src/api2/config/sync.rs | 41 +++++++++++++------ > src/api2/node/tasks.rs | 4 +- > src/api2/pull.rs | 68 +++++++++++++++++++++++-------- > src/server/email_notifications.rs | 16 ++++---- > 6 files changed, 93 insertions(+), 42 deletions(-) > > diff --git a/src/api2/pull.rs b/src/api2/pull.rs > index b2473ec8..bb8f6fe1 100644 > --- a/src/api2/pull.rs > +++ b/src/api2/pull.rs > @@ -64,7 +75,7 @@ impl TryFrom<&SyncJobConfig> for PullParameters { > PullParameters::new( > &sync_job.store, > sync_job.ns.clone().unwrap_or_default(), > - &sync_job.remote, > + sync_job.remote.clone().as_deref(), ^ unnecessary .clone() > &sync_job.remote_store, > sync_job.remote_ns.clone().unwrap_or_default(), > sync_job > @@ -75,7 +86,6 @@ impl TryFrom<&SyncJobConfig> for PullParameters { > sync_job.remove_vanished, > sync_job.max_depth, > sync_job.group_filter.clone(), > - sync_job.limit.clone(), > ) > } > } > diff --git a/src/server/email_notifications.rs b/src/server/email_notifications.rs > index b3298cf9..31a46b0f 100644 > --- a/src/server/email_notifications.rs > +++ b/src/server/email_notifications.rs > @@ -486,15 +486,15 @@ pub fn send_sync_status( > } > }; > You can declare a binding here to: let tmp_src_string; > + let source_str = if let Some(remote) = job.remote.clone() { You can borrow here instead of cloning. > + format!("Sync remote '{}'", remote) You can assign `tmp_src_string` here, and return &tmp_src_string from the block. (and remote can go into the `{}` portion) let tmp_src_string = format!("Sync remote '{remote}'"); &tmp_src_string > + } else { > + format!("Sync local") And drop the `format!()` here altogether and just use "Sync local". With the `tmp_src_string` being outside the `if` scope this will allow the string w/o a remote to just reference the `&'static str` instead of allocating. > + }; > + > let subject = match result { > - Ok(()) => format!( > - "Sync remote '{}' datastore '{}' successful", > - job.remote, job.remote_store, > - ), > - Err(_) => format!( > - "Sync remote '{}' datastore '{}' failed", > - job.remote, job.remote_store, > - ), > + Ok(()) => format!("{} datastore '{}' successful", source_str, job.remote_store,), > + Err(_) => format!("{} datastore '{}' failed", source_str, job.remote_store,), > }; > > send_job_status_mail(email, &subject, &text)?; > -- > 2.30.2