Skip to content

Commit b56d9c3

Browse files
committed
make szre deletes are not added altough there is updates in that intent
1 parent 15a1425 commit b56d9c3

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

pkg/datastore/transaction_rpc.go

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,6 @@ func (d *Datastore) lowlevelTransactionSet(ctx context.Context, transaction *typ
190190
return nil, err
191191
}
192192

193-
// we need to curate a list of all the paths involved, of the old and new intent contents.
194-
// this is then used to load the IntendedStore highes prio into the tree, to decide if an update
195-
// is to be applied or if a higher precedence update exists and is therefore not applicable. Also if the value got
196-
// deleted and a previousely shadowed entry becomes active.
197-
involvedPaths := treetypes.NewPathSet()
198-
199193
// create a flags attribute
200194
flagNew := treetypes.NewUpdateInsertFlags()
201195
// where the New flag is set
@@ -223,19 +217,16 @@ func (d *Datastore) lowlevelTransactionSet(ctx context.Context, transaction *typ
223217
return nil, err
224218
}
225219

226-
// add the content to the Tree
227-
err = root.AddUpdatesRecursive(ctx, intent.GetUpdates(), flagNew)
228-
if err != nil {
229-
return nil, err
230-
}
231-
232-
// add the explicit delete entries
233-
root.AddExplicitDeletes(intent.GetName(), intent.GetPriority(), intent.GetDeletes())
220+
if !intent.GetDeleteFlag() {
221+
// add the content to the Tree
222+
err = root.AddUpdatesRecursive(ctx, intent.GetUpdates(), flagNew)
223+
if err != nil {
224+
return nil, err
225+
}
234226

235-
// add the old intent contents paths to the involvedPaths slice
236-
involvedPaths.Join(oldIntentContent.ToPathSet())
237-
// add the new intent contents paths to the involvedPaths slice
238-
involvedPaths.Join(intent.GetUpdates().ToPathSet())
227+
// add the explicit delete entries
228+
root.AddExplicitDeletes(intent.GetName(), intent.GetPriority(), intent.GetDeletes())
229+
}
239230
}
240231

241232
les := tree.LeafVariantSlice{}

pkg/datastore/types/transaction_intent.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ func (ti *TransactionIntent) GetUpdates() treetypes.UpdateSlice {
4545
return ti.updates
4646
}
4747

48+
func (ti *TransactionIntent) GetDeleteFlag() bool {
49+
return ti.delete
50+
}
51+
4852
func (ti *TransactionIntent) GetDeletes() *sdcpb.PathSet {
4953
return ti.explicitDeletes
5054
}

pkg/tree/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (s *sharedEntryAttributes) toJsonInternal(onlyNewOrUpdated bool, ietf bool)
118118
}
119119

120120
case *sdcpb.SchemaElem_Leaflist, *sdcpb.SchemaElem_Field:
121-
if s.leafVariants.canDeleteBranch(false) {
121+
if s.leafVariants.canDelete() {
122122
return nil, nil
123123
}
124124
le := s.leafVariants.GetHighestPrecedence(onlyNewOrUpdated, false, false)

pkg/tree/leaf_variants.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,12 @@ func (lv *LeafVariants) GetHighestPrecedence(onlyNewOrUpdated bool, includeDefau
285285
}
286286
}
287287

288-
// do not include defaults loaded at validation time
289-
if checkNotDefaultAllowedButIsDefaultOwner(highest, includeDefaults) {
288+
if highest.IsExplicitDelete && !includeExplicitDelete {
290289
return nil
291290
}
292291

293-
if highest.IsExplicitDelete && !includeExplicitDelete {
292+
// do not include defaults loaded at validation time
293+
if checkNotDefaultAllowedButIsDefaultOwner(highest, includeDefaults) {
294294
return nil
295295
}
296296

0 commit comments

Comments
 (0)