summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Estabrook <jestabro@vyos.io>2025-08-18 22:38:10 -0500
committerJohn Estabrook <jestabro@vyos.io>2025-08-19 09:29:53 -0500
commitb46b74b48f7db04a46d0ba7caa512dc70b5fcccd (patch)
tree1b8d0d738d1d46ea11a08bfd39eade34a1b1bfff /src
parent28efcd85149bb284b7835c360dd2cfeab2f92aa2 (diff)
downloadvyconf-b46b74b48f7db04a46d0ba7caa512dc70b5fcccd.tar.gz
vyconf-b46b74b48f7db04a46d0ba7caa512dc70b5fcccd.zip
T7734: distinguish childless non-leaf nodes in set operation
Diffstat (limited to 'src')
-rw-r--r--src/session.ml18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/session.ml b/src/session.ml
index f8bc843..5efc9f5 100644
--- a/src/session.ml
+++ b/src/session.ml
@@ -53,20 +53,26 @@ let string_of_op op =
| None -> Printf.sprintf "delete %s" path_str
| Some v -> Printf.sprintf "delete %s \"%s\"" path_str v)
-
let set_modified s =
if s.modified = true then s
else {s with modified = true}
let apply_cfg_op w op config =
- let config =
+ let result =
match op with
| CfgSet (path, value, value_behaviour) ->
begin
+ let rt = w.reference_tree in
+ let refp = RT.refpath rt path in
try
- CT.set config path value value_behaviour |>
- (fun c -> RT.set_tag_data w.reference_tree c path) |>
- (fun c -> RT.set_leaf_data w.reference_tree c path)
+ let c =
+ match (RT.is_leaf rt refp) with
+ | true ->
+ CT.set config path value value_behaviour
+ | false ->
+ CT.create_node config path
+ in
+ RT.set_tag_data rt c path
with
| CT.Useless_set | CT.Duplicate_value -> config
end
@@ -78,7 +84,7 @@ let apply_cfg_op w op config =
with
| VT.Nonexistent_path | CT.No_such_value -> config
end
- in config
+ in result
let rec apply_changes w changeset config =
match changeset with