Revert premature default optimize fix

This commit is contained in:
Olof hagsand 2024-01-09 10:59:34 +01:00
parent 7b5dc3d24c
commit 907da6ab9a
2 changed files with 8 additions and 8 deletions

View file

@ -1003,10 +1003,8 @@ xmldb_get_cache(clixon_handle h,
goto done; goto done;
} }
/* Original tree: Remove global defaults and empty non-presence containers */ /* Original tree: Remove global defaults and empty non-presence containers */
#if 0
if (xml_defaults_nopresence(x0t, 2) < 0) if (xml_defaults_nopresence(x0t, 2) < 0)
goto done; goto done;
#endif
switch (wdef){ switch (wdef){
case WITHDEFAULTS_REPORT_ALL: case WITHDEFAULTS_REPORT_ALL:
break; break;

View file

@ -582,14 +582,17 @@ text_modify(clixon_handle h,
x1bstr = xml_body(x1); x1bstr = xml_body(x1);
switch(op){ switch(op){
case OP_CREATE: case OP_CREATE:
if (x0){ if (x0 && xml_flag(x0, XML_FLAG_DEFAULT)==0){
if (netconf_data_exists(cbret, "Data already exists; cannot create new resource") < 0) if (netconf_data_exists(cbret, "Data already exists; cannot create new resource") < 0)
goto done; goto done;
goto fail; goto fail;
} }
case OP_REPLACE: /* fall thru */ case OP_REPLACE: /* fall thru */
case OP_MERGE: case OP_MERGE:
if (!(op == OP_MERGE && instr==NULL)){ /* If default flag, clear it */
if (x0 && xml_flag(x0, XML_FLAG_DEFAULT))
xml_flag_reset(x0, XML_FLAG_DEFAULT);
if (!(op == OP_MERGE && (instr==NULL))) {
/* Remove existing, also applies to merge in the special case /* Remove existing, also applies to merge in the special case
* of ordered-by user and (changed) insert attribute. * of ordered-by user and (changed) insert attribute.
*/ */
@ -710,7 +713,7 @@ text_modify(clixon_handle h,
} }
break; break;
case OP_DELETE: case OP_DELETE:
if (x0==NULL){ if (x0==NULL || xml_flag(x0, XML_FLAG_DEFAULT) != 0){
if (netconf_data_missing(cbret, "Data does not exist; cannot delete resource") < 0) if (netconf_data_missing(cbret, "Data does not exist; cannot delete resource") < 0)
goto done; goto done;
goto fail; goto fail;
@ -780,7 +783,7 @@ text_modify(clixon_handle h,
} }
switch(op){ switch(op){
case OP_CREATE: case OP_CREATE:
if (x0){ if (x0 && xml_flag(x0, XML_FLAG_DEFAULT)==0){
if (xml_defaults_nopresence(x0, 0) == 0){ if (xml_defaults_nopresence(x0, 0) == 0){
if (netconf_data_exists(cbret, "Data already exists; cannot create new resource") < 0) if (netconf_data_exists(cbret, "Data already exists; cannot create new resource") < 0)
goto done; goto done;
@ -973,7 +976,7 @@ text_modify(clixon_handle h,
} }
break; break;
case OP_DELETE: case OP_DELETE:
if (x0==NULL){ if (x0==NULL || xml_flag(x0, XML_FLAG_DEFAULT) != 0){
if (netconf_data_missing(cbret, "Data does not exist; cannot delete resource") < 0) if (netconf_data_missing(cbret, "Data does not exist; cannot delete resource") < 0)
goto done; goto done;
goto fail; goto fail;
@ -1304,7 +1307,6 @@ xmldb_put(clixon_handle h,
} }
goto fail; goto fail;
} }
/* Remove NONE nodes if all subs recursively are also NONE */ /* Remove NONE nodes if all subs recursively are also NONE */
if (xml_tree_prune_flagged_sub(x0, XML_FLAG_NONE, 0, NULL) <0) if (xml_tree_prune_flagged_sub(x0, XML_FLAG_NONE, 0, NULL) <0)
goto done; goto done;