Delete CLI metadata through the replaced subtree
This commit is contained in:
@@ -2,7 +2,6 @@ package engine
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"gitea.maximumdirect.net/eric/ConfigKit/internal/document"
|
||||
)
|
||||
@@ -171,17 +170,16 @@ func updateOverridePresence(presence map[string]inputPresence, existing, incomin
|
||||
return
|
||||
}
|
||||
|
||||
deletePresencePathSubtree(presence, path)
|
||||
deletePresencePathSubtree(presence, existing, path)
|
||||
collectPresence(incoming, path, presence)
|
||||
}
|
||||
|
||||
func deletePresencePathSubtree(presence map[string]inputPresence, path Path) {
|
||||
pointer := path.String()
|
||||
for candidate := range presence {
|
||||
if candidate == pointer || strings.HasPrefix(candidate, pointer+"/") {
|
||||
delete(presence, candidate)
|
||||
}
|
||||
}
|
||||
func deletePresencePathSubtree(presence map[string]inputPresence, existing *document.Node, path Path) {
|
||||
// The typed pre-CLI tree contains every effective descendant. Visit only
|
||||
// the replaced subtree rather than searching unrelated metadata entries.
|
||||
walkDocument(existing, path, func(path Path, _ *document.Node) {
|
||||
delete(presence, path.String())
|
||||
})
|
||||
}
|
||||
|
||||
func updateOverrideOrigins(origins map[string]Origin, existing, incoming *document.Node, path Path, location document.Location) {
|
||||
@@ -200,12 +198,9 @@ func updateOverrideOrigins(origins map[string]Origin, existing, incoming *docume
|
||||
return
|
||||
}
|
||||
|
||||
pointer := path.String()
|
||||
for candidate := range origins {
|
||||
if candidate == pointer || strings.HasPrefix(candidate, pointer+"/") {
|
||||
delete(origins, candidate)
|
||||
}
|
||||
}
|
||||
walkDocument(existing, path, func(path Path, _ *document.Node) {
|
||||
delete(origins, path.String())
|
||||
})
|
||||
collectOverlayOrigins(origins, incoming, path, LayerCLI)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user