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(())