MCPcopy Create free account
hub / github.com/pydio/cells / Diff

Method Diff

common/utils/watch/diff.go:50–96  ·  view source on GitHub ↗
(dt diff.DiffType, df diff.DiffFunc, cl *diff.Changelog, path []string, a, b reflect.Value, parent interface{})

Source from the content-addressed store, hash-verified

48}
49
50func (s *syncMapDiffer) Diff(dt diff.DiffType, df diff.DiffFunc, cl *diff.Changelog, path []string, a, b reflect.Value, parent interface{}) error {
51 // Checking what's been added
52 sma := a.Interface().(*sync.Map)
53 smb := b.Interface().(*sync.Map)
54
55 sma.Range(func(ka any, va any) bool {
56 found := false
57 smb.Range(func(kb any, vb any) bool {
58 if ka == kb {
59 // Must diff ka && kb
60 found = true
61 s.DiffFunc(append(path, ka.(string)), reflect.ValueOf(va), reflect.ValueOf(vb), nil)
62 }
63
64 return true
65 })
66
67 // Has been added
68 if !found {
69 cl.Add(diff.DELETE, append(path, ka.(string)), va, nil)
70 }
71
72 return true
73 })
74
75 smb.Range(func(kb any, vb any) bool {
76 found := false
77 sma.Range(func(ka any, _ any) bool {
78 if ka == kb {
79 // Must diff ka && kb
80 found = true
81 return false
82 }
83
84 return true
85 })
86
87 // Has been added
88 if !found {
89 cl.Add(diff.CREATE, append(path, kb.(string)), nil, vb)
90 }
91
92 return true
93 })
94
95 return nil
96}
97
98func (s *syncMapDiffer) InsertParentDiffer(dfunc func(path []string, a, b reflect.Value, p interface{}) error) {
99 s.DiffFunc = dfunc

Callers

nothing calls this directly

Calls 2

InterfaceMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected