32 lines
657 B
Go
32 lines
657 B
Go
package vaultview
|
|
|
|
import "git.julianfamily.org/keepassgo/internal/vault"
|
|
|
|
// HiddenRoot returns the single synthetic top-level vault group that should be
|
|
// treated as an internal storage root rather than as a user-visible group.
|
|
func HiddenRoot(model vault.Model) string {
|
|
if !hasGroup(model.Groups, []string{KeepassRoot}) {
|
|
return ""
|
|
}
|
|
return KeepassRoot
|
|
}
|
|
|
|
func hasGroup(groups [][]string, path []string) bool {
|
|
for _, group := range groups {
|
|
if len(group) != len(path) {
|
|
continue
|
|
}
|
|
match := true
|
|
for i := range group {
|
|
if group[i] != path[i] {
|
|
match = false
|
|
break
|
|
}
|
|
}
|
|
if match {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|