From bfc575b7cd8dfa95ad31754e691b33ef76d41313 Mon Sep 17 00:00:00 2001 From: Ryo Kawaguchi Date: Mon, 22 Apr 2024 21:15:16 +0900 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Matěj Laitl Co-authored-by: Jake McGinty --- client/src/main.rs | 7 +++---- server/src/db/cidr.rs | 1 + server/src/main.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index 0d52926..0f7f8e6 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -754,10 +754,9 @@ fn rename_cidr( let id = cidrs .iter() - .filter(|c| c.name == old_name) - .map(|c| c.id) - .next() - .ok_or_else(|| anyhow!("CIDR not found."))?; + .find(|c| c.name == old_name) + .ok_or_else(|| anyhow!("CIDR not found."))? + .id; api.http_form("PUT", &format!("/admin/cidrs/{id}"), cidr_request)?; log::info!("CIDR renamed."); diff --git a/server/src/db/cidr.rs b/server/src/db/cidr.rs index ec1a935..8e1c019 100644 --- a/server/src/db/cidr.rs +++ b/server/src/db/cidr.rs @@ -113,6 +113,7 @@ impl DatabaseCidr { } /// Update self with new contents, validating them and updating the backend in the process. + /// Currently this only supports updating the name and ignores changes to any other field. pub fn update(&mut self, conn: &Connection, contents: CidrContents) -> Result<(), ServerError> { let new_contents = CidrContents { name: contents.name, diff --git a/server/src/main.rs b/server/src/main.rs index cb82ff6..a65ca74 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -485,7 +485,7 @@ fn rename_cidr( .ok_or_else(|| anyhow!("CIDR not found."))?; db::DatabaseCidr::from(db_cidr).update(&conn, cidr_request)?; } else { - println!("exited without creating CIDR."); + println!("exited without renaming CIDR."); } Ok(())