From b153ccc2c3b82775d15657c273b00be0b48e4628 Mon Sep 17 00:00:00 2001 From: neonbit101 Date: Tue, 20 Jan 2026 13:09:26 +0530 Subject: [PATCH 1/2] fix(network): make forget() and forget_vpn() idempotent --- nmrs/src/core/connection.rs | 2 +- nmrs/src/core/vpn.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nmrs/src/core/connection.rs b/nmrs/src/core/connection.rs index 9ca33956..7a0acf13 100644 --- a/nmrs/src/core/connection.rs +++ b/nmrs/src/core/connection.rs @@ -412,7 +412,7 @@ pub(crate) async fn forget_by_name_and_type( debug!("Bluetooth device '{name}' has no NetworkManager connection profile (device may only be paired in BlueZ)"); Ok(()) } else { - Err(ConnectionError::NoSavedConnection) + Ok(()) } } } diff --git a/nmrs/src/core/vpn.rs b/nmrs/src/core/vpn.rs index b7a57bb8..013937b7 100644 --- a/nmrs/src/core/vpn.rs +++ b/nmrs/src/core/vpn.rs @@ -571,7 +571,7 @@ pub(crate) async fn forget_vpn(conn: &Connection, name: &str) -> Result<()> { } debug!("No saved VPN connection found for '{name}'"); - Err(crate::api::models::ConnectionError::NoSavedConnection) + Ok(()) } /// Gets detailed information about a WireGuard connection. From d8860c19e8d3d07cf022c435e58da9a08cc21149 Mon Sep 17 00:00:00 2001 From: neonbit101 Date: Tue, 20 Jan 2026 13:11:39 +0530 Subject: [PATCH 2/2] docs(network): update docstrings for idempotency --- nmrs/src/api/network_manager.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nmrs/src/api/network_manager.rs b/nmrs/src/api/network_manager.rs index e65f3e25..033789e6 100644 --- a/nmrs/src/api/network_manager.rs +++ b/nmrs/src/api/network_manager.rs @@ -366,8 +366,8 @@ impl NetworkManager { /// /// # Errors /// - /// Returns `ConnectionError::NoSavedConnection` if no VPN with the given - /// name is found. + /// Returns an error only if the operation fails unexpectedly. + /// Returns `Ok(())` if no matching VPN connection is found. pub async fn forget_vpn(&self, name: &str) -> Result<()> { crate::core::vpn::forget_vpn(&self.conn, name).await } @@ -555,8 +555,8 @@ impl NetworkManager { /// /// # Returns /// - /// Returns `Ok(())` if at least one connection was deleted successfully. - /// Returns `NoSavedConnection` if no matching connections were found. + /// Returns `Ok(())` if one or more connections were deleted successfully, + /// or if no matching connections were found. pub async fn forget(&self, ssid: &str) -> Result<()> { forget_by_name_and_type( &self.conn,