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 95B45619D6 for ; Fri, 20 Nov 2020 17:40:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8C90C153BA for ; Fri, 20 Nov 2020 17:40:11 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 id 10209153B0 for ; Fri, 20 Nov 2020 17:40:11 +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 CE89943D43 for ; Fri, 20 Nov 2020 17:40:10 +0100 (CET) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pbs-devel@lists.proxmox.com Date: Fri, 20 Nov 2020 17:38:41 +0100 Message-Id: <20201120163845.1225080-12-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201120163845.1225080-1-f.gruenbichler@proxmox.com> References: <20201120163845.1225080-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.025 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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. [datastore.rs] Subject: [pbs-devel] [PATCH proxmox-backup 11/13] refactor BackupInfo -> SnapshotListItem helper 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: Fri, 20 Nov 2020 16:40:41 -0000 before adding more fields to the tuple, let's just create the struct inside the match arms to improve readability. Signed-off-by: Fabian Grünbichler --- Notes: new in v2 src/api2/admin/datastore.rs | 50 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 872d081e..de0c8de3 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -391,9 +391,11 @@ pub fn list_snapshots ( }; let info_to_snapshot_list_item = |group: &BackupGroup, owner, info: BackupInfo| { + let backup_type = group.backup_type().to_string(); + let backup_id = group.backup_id().to_string(); let backup_time = info.backup_dir.backup_time(); - let (comment, verification, files, size) = match get_all_snapshot_files(&datastore, &info) { + match get_all_snapshot_files(&datastore, &info) { Ok((manifest, files)) => { // extract the first line from notes let comment: Option = manifest.unprotected["notes"] @@ -401,8 +403,8 @@ pub fn list_snapshots ( .and_then(|notes| notes.lines().next()) .map(String::from); - let verify = manifest.unprotected["verify_state"].clone(); - let verify: Option = match serde_json::from_value(verify) { + let verification = manifest.unprotected["verify_state"].clone(); + let verification: Option = match serde_json::from_value(verification) { Ok(verify) => verify, Err(err) => { eprintln!("error parsing verification state : '{}'", err); @@ -412,14 +414,20 @@ pub fn list_snapshots ( let size = Some(files.iter().map(|x| x.size.unwrap_or(0)).sum()); - (comment, verify, files, size) + SnapshotListItem { + backup_type, + backup_id, + backup_time, + comment, + verification, + files, + size, + owner, + } }, Err(err) => { eprintln!("error during snapshot file listing: '{}'", err); - ( - None, - None, - info + let files = info .files .into_iter() .map(|x| BackupContent { @@ -427,21 +435,19 @@ pub fn list_snapshots ( size: None, crypt_mode: None, }) - .collect(), - None, - ) + .collect(); + + SnapshotListItem { + backup_type, + backup_id, + backup_time, + comment: None, + verification: None, + files, + size: None, + owner, + } }, - }; - - SnapshotListItem { - backup_type: group.backup_type().to_string(), - backup_id: group.backup_id().to_string(), - backup_time, - comment, - verification, - files, - size, - owner, } }; -- 2.20.1