From 4b9bb22c87ba0b29623fd310abd7d0dbfca4e33e Mon Sep 17 00:00:00 2001 From: lzt404 <2596933790@qq.com> Date: Mon, 28 Sep 2026 12:59:39 +0800 Subject: [PATCH] Delete redundant code --- src-tauri/src/core_config/yaml.rs | 16 ---------------- src-tauri/src/tests/core_config.rs | 6 +----- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src-tauri/src/core_config/yaml.rs b/src-tauri/src/core_config/yaml.rs index 799b467..936fdf0 100644 --- a/src-tauri/src/core_config/yaml.rs +++ b/src-tauri/src/core_config/yaml.rs @@ -1184,22 +1184,6 @@ pub(crate) fn yaml_edit_node_from_value( .ok_or_else(|| "Unable to construct kernel configuration value".to_string()) } -pub(crate) fn set_core_yaml_top_level_value( - document: &mut serde_norway::Value, - key: &str, - value: serde_norway::Value, -) -> Result { - let root = document - .as_mapping_mut() - .ok_or_else(|| "Kernel configuration root must be a YAML mapping".to_string())?; - let key = yaml_key(key); - if root.get(&key) == Some(&value) { - return Ok(false); - } - root.insert(key, value); - Ok(true) -} - pub(crate) fn set_core_yaml_nested_value( document: &mut serde_norway::Value, section: &str, diff --git a/src-tauri/src/tests/core_config.rs b/src-tauri/src/tests/core_config.rs index 9973339..7396eef 100644 --- a/src-tauri/src/tests/core_config.rs +++ b/src-tauri/src/tests/core_config.rs @@ -1264,11 +1264,7 @@ fn yaml_edit_sequence_shrink_keeps_following_top_level_key_valid() { fn runtime_yaml_ast_patch_handles_core_comments_around_nested_mapping() { let input = "host: 127.0.0.1\nremote-management:\n# Whether to allow remote access.\n allow-remote: false\n# Management key.\n# All requests require this key.\n secret-key: old\n# Disable panel.\n disable-control-panel: false\nauth-dir: /tmp/old\napi-keys:\n - old-key\n"; let rendered = patch_core_yaml_document(input, |document| { - let auth_changed = set_core_yaml_top_level_value( - document, - "auth-dir", - serde_norway::Value::String("/tmp/new".to_string()), - )?; + let auth_changed = set_core_yaml_auth_dir(document, "/tmp/new")?; let secret_changed = set_core_yaml_nested_value( document, "remote-management",