|
16 | 16 | #include "y_utils.h" |
17 | 17 | #include "src/onm_logger.h" |
18 | 18 |
|
19 | | - |
20 | 19 | struct lyd_node *parent_data = NULL; |
21 | 20 |
|
22 | 21 | void free_parent_data() { |
@@ -207,12 +206,17 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t |
207 | 206 |
|
208 | 207 | int item_found = 1; |
209 | 208 | // check if the node exist in the tree, if not create new node in the tree. |
210 | | - ret = lyd_find_path(parent_data, xpath, 0, &new_parent); |
211 | | - if (ret == LY_ENOTFOUND) |
212 | | - item_found = 0; |
213 | | - if (new_parent == NULL || ret == LY_EINCOMPLETE) { |
| 209 | + if (parent_data == NULL) { |
214 | 210 | ret = lyd_new_path(parent_data, sysrepo_ctx, xpath, NULL, LYD_NEW_PATH_UPDATE, &new_parent); |
| 211 | + } else { |
| 212 | + ret = lyd_find_path(parent_data, xpath, 0, &new_parent); |
| 213 | + if (ret == LY_ENOTFOUND) |
| 214 | + item_found = 0; |
| 215 | + if (new_parent == NULL || ret == LY_EINCOMPLETE) { |
| 216 | + ret = lyd_new_path(parent_data, sysrepo_ctx, xpath, NULL, LYD_NEW_PATH_UPDATE, &new_parent); |
| 217 | + } |
215 | 218 | } |
| 219 | + |
216 | 220 | if (ret != LY_SUCCESS) |
217 | 221 | break; |
218 | 222 | // if the edit operation is 'add', then update the parent_node, else (which is 'delete' operation) then just set the out node. |
@@ -253,7 +257,7 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t |
253 | 257 | if (new_leaf == NULL) { |
254 | 258 | item_found = 0; |
255 | 259 | ret = lyd_new_path2(parent_data, sysrepo_ctx, xpath, value, strlen(value), LYD_ANYDATA_STRING, |
256 | | - LYD_NEW_PATH_OUTPUT, NULL, &new_leaf); |
| 260 | + 0, NULL, &new_leaf); |
257 | 261 | } |
258 | 262 |
|
259 | 263 |
|
|
0 commit comments