diff --git a/cosmic-settings/src/pages/networking/vpn/mod.rs b/cosmic-settings/src/pages/networking/vpn/mod.rs index 4e8c150..ff85a8f 100644 --- a/cosmic-settings/src/pages/networking/vpn/mod.rs +++ b/cosmic-settings/src/pages/networking/vpn/mod.rs @@ -95,6 +95,7 @@ pub enum ErrorKind { ConnectionEditor, ConnectionSettings, DbusConnection, + OpenVpnConfigPath, UpdatingState, WireGuardConfigPath, WireGuardDevice, @@ -109,6 +110,7 @@ impl ErrorKind { ErrorKind::ConnectionEditor => fl!("vpn-error", "connection-editor"), ErrorKind::ConnectionSettings => fl!("vpn-error", "connection-settings"), ErrorKind::DbusConnection => fl!("dbus-connection-error"), + ErrorKind::OpenVpnConfigPath => fl!("vpn-error", "openvpn-config-path"), ErrorKind::UpdatingState => fl!("vpn-error", "updating-state"), ErrorKind::WireGuardConfigPath => fl!("vpn-error", "wireguard-config-path"), ErrorKind::WireGuardDevice => fl!("vpn-error", "wireguard-device"), @@ -1199,8 +1201,14 @@ fn add_network() -> Task { return Message::AddWireGuardDevice(device, filename.to_owned(), path); } else { - super::nm_add_vpn_file("openvpn", response.url().to_file_path().unwrap()) - .await + let Ok(path) = response.url().to_file_path() else { + return Message::Error( + ErrorKind::OpenVpnConfigPath, + fl!("vpn-error", "openvpn-config-path-desc"), + ); + }; + + super::nm_add_vpn_file("openvpn", path).await }; match result { diff --git a/i18n/en/cosmic_settings.ftl b/i18n/en/cosmic_settings.ftl index ac509cd..0edc525 100644 --- a/i18n/en/cosmic_settings.ftl +++ b/i18n/en/cosmic_settings.ftl @@ -198,6 +198,8 @@ vpn-error = VPN Error .connect = Failed to connect to VPN .connection-editor = Connection editor failed .connection-settings = Failed to get settings for active connections + .openvpn-config-path = Invalid file path for OpenVPN config + .openvpn-config-path-desc = Chosen file must be on a local file system. .updating-state = Failed to update network manager state .wireguard-config-path = Invalid file path for WireGuard config .wireguard-config-path-desc = Chosen file must be on a local file system.