Skip to content

Commit

Permalink
Work-around for clicon/clixon#475
Browse files Browse the repository at this point in the history
Remove duplicate delete/adds
  • Loading branch information
olofhagsand committed Jan 6, 2024
1 parent a4246db commit 2db0016
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@
*/
#define SHARED_PROFILE_YSPEC

/*! Workaround for https://github.com/clicon/clixon/issues/475
*
* Diff is broken, a deleted object may also be added:
* Go thru deleted and added, and delete both if they are equal
*/
#define DELETE_WORKAROUND

#define ACTION_PROCESS "Action process"

#endif /* _CONTROLLER_H */
24 changes: 24 additions & 0 deletions src/controller_rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,30 @@ push_device_one(clixon_handle h,
&avec, &alen,
&chvec0, &chvec1, &chlen) < 0)
goto done;
#ifdef DELETE_WORKAROUND
/* Go thru deleted and added, and delete both if they are equal */
if (dlen && alen){
int i;
int j;
cxobj *xd;
cxobj *xa;
for (i=0; i<dlen; i++){
xd = dvec[i];
for (j=0; j<alen; j++){
xa = avec[j];
if (xml_cmp(xd,xa,0,0,NULL)==0)
break;
}
if (j < alen){
memmove(&avec[j], &avec[j+1], (alen-j)*sizeof(cxobj*));
alen--;
memmove(&dvec[i], &dvec[i+1], (dlen-i)*sizeof(cxobj*));
dlen--;
i--;
}
}
}
#endif
/* 3) construct an edit-config, send it and validate it */
if (dlen || alen || chlen){
if (device_create_edit_config_diff(h, dh,
Expand Down

0 comments on commit 2db0016

Please sign in to comment.