added prefix scan and fixed logout issue

This commit is contained in:
ston1th 2019-07-06 11:31:12 +02:00
commit 8143e484cd
12 changed files with 99 additions and 77 deletions

View file

@ -17,12 +17,10 @@ var (
)
func (db *DB) GetSections() (secs core.Sections, err error) {
err = db.store.ForEach(func(k string, _ []byte) error {
if trim, ok := hasTrimPrefix(k, sectionPrefix); ok {
s, err := db.GetSection(trim)
if err == nil {
secs = append(secs, s)
}
err = db.store.ForEachPrefix(sectionPrefix, func(k string, _ []byte) error {
s, err := db.GetSection(k)
if err == nil {
secs = append(secs, s)
}
return nil
})
@ -96,11 +94,9 @@ func (db *DB) DeleteSection(section string) error {
}
section += "/"
var pages []string
db.store.ForEach(func(k string, _ []byte) error {
if trim, ok := hasTrimPrefix(k, pagePrefix); ok {
if strings.HasPrefix(trim, section) {
pages = append(pages, trim)
}
db.store.ForEachPrefix(pagePrefix, func(k string, _ []byte) error {
if strings.HasPrefix(k, section) {
pages = append(pages, k)
}
return nil
})