Skip to content

Commit 1e6f457

Browse files
Merge pull request #280 from sdcio/StreamlineDeleteEntyImpl
remove additionsl pathslice attribute, calculate it from sdcpb.path
2 parents 9fa8e33 + a924725 commit 1e6f457

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pkg/tree/sharedEntryAttributes.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,7 @@ func (s *sharedEntryAttributes) remainsToExist() bool {
610610
// getRegularDeletes performs deletion calculation on elements that have a schema attached.
611611
func (s *sharedEntryAttributes) getRegularDeletes(deletes []types.DeleteEntry, aggregate bool) ([]types.DeleteEntry, error) {
612612
var err error
613+
613614
if s.shouldDelete() && !s.IsRoot() && len(s.GetSchemaKeys()) == 0 {
614615
return append(deletes, s), nil
615616
}
@@ -619,7 +620,8 @@ func (s *sharedEntryAttributes) getRegularDeletes(deletes []types.DeleteEntry, a
619620
if err != nil {
620621
return nil, err
621622
}
622-
deletes = append(deletes, types.NewDeleteEntryImpl(path, append(s.Path(), elem)))
623+
path.Elem = append(path.Elem, &sdcpb.PathElem{Name: elem})
624+
deletes = append(deletes, types.NewDeleteEntryImpl(path))
623625
}
624626

625627
for _, e := range s.childs.GetAll() {

pkg/tree/types/delete_entry.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package types
22

33
import (
4+
"github.com/sdcio/data-server/pkg/utils"
45
sdcpb "github.com/sdcio/sdc-protos/sdcpb"
56
)
67

@@ -12,21 +13,19 @@ type DeleteEntry interface {
1213
// DeleteEntryImpl is a crutch to flag oldbestcases if on a choice, the active case changed
1314
type DeleteEntryImpl struct {
1415
sdcpbPath *sdcpb.Path
15-
pathslice PathSlice
1616
}
1717

18-
func NewDeleteEntryImpl(sdcpbPath *sdcpb.Path, pathslice PathSlice) *DeleteEntryImpl {
18+
func NewDeleteEntryImpl(sdcpbPath *sdcpb.Path) *DeleteEntryImpl {
1919
return &DeleteEntryImpl{
2020
sdcpbPath: sdcpbPath,
21-
pathslice: pathslice,
2221
}
2322
}
2423

2524
func (d *DeleteEntryImpl) SdcpbPath() (*sdcpb.Path, error) {
2625
return d.sdcpbPath, nil
2726
}
2827
func (d *DeleteEntryImpl) Path() PathSlice {
29-
return d.pathslice
28+
return utils.ToStrings(d.sdcpbPath, false, false)
3029
}
3130

3231
type DeleteEntriesList []DeleteEntry

0 commit comments

Comments
 (0)