Skip to content

Commit df96385

Browse files
committed
sysrepo UPDATE distinguish strict deletion for oper DS
1 parent cf8d1bd commit df96385

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/sysrepo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,7 +3521,8 @@ sr_delete_item(sr_session_ctx_t *session, const char *path, const sr_edit_option
35213521
uint32_t temp_lo = 0;
35223522
int rc;
35233523

3524-
SR_CHECK_ARG_APIRET(!session || !path || SR_EDIT_DS_API_CHECK(session->ds, opts), session, err_info);
3524+
SR_CHECK_ARG_APIRET(!session || !path || !SR_IS_STANDARD_DS(session->ds) || (!SR_IS_CONVENTIONAL_DS(session->ds) &&
3525+
(opts & (SR_EDIT_NON_RECURSIVE | SR_EDIT_ISOLATE))), session, err_info);
35253526

35263527
if (!session->dt[session->ds].edit && (session->ds == SR_DS_OPERATIONAL)) {
35273528
/* prepare the current stored oper data to be modified */
@@ -3559,7 +3560,7 @@ sr_delete_item(sr_session_ctx_t *session, const char *path, const sr_edit_option
35593560
}
35603561
if (node) {
35613562
sr_lyd_free_tree_safe(node, &session->dt[session->ds].edit->tree);
3562-
} else {
3563+
} else if (opts & SR_EDIT_STRICT) {
35633564
/* not found */
35643565
sr_errinfo_new(&err_info, SR_ERR_NOT_FOUND, "Node \"%s\" not found in session push oper data.", path);
35653566
}

src/sysrepo.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,8 @@ int sr_set_item_str(sr_session_ctx_t *session, const char *path, const char *val
954954
* changes merged into the list, use ::SR_EDIT_ISOLATE in such a case.
955955
*
956956
* For ::SR_DS_OPERATIONAL, this function deletes the selected node from the session push oper data. To delete the node
957-
* from the final operational datastore, use ::sr_discard_items() instead. No option is allowed for this datastore.
957+
* from the final operational datastore, use ::sr_discard_items() instead. Only ::SR_EDIT_STRICT option is allowed
958+
* causing the function to return an error if the deleted node does not exist in the session push oper data.
958959
*
959960
* @param[in] session Session ([DS](@ref sr_datastore_t)-specific) to use.
960961
* @param[in] path [Path](@ref paths) identifier of the data element to be deleted.

0 commit comments

Comments
 (0)