mirror of
https://codeberg.org/Codeberg/pages-server.git
synced 2025-04-25 06:16:58 +00:00
next
This commit is contained in:
parent
1715e88910
commit
52a3b48016
9 changed files with 174 additions and 74 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
|
@ -62,8 +63,32 @@ func (p aDB) Compact() (string, error) {
|
|||
return fmt.Sprintf("%+v", result), nil
|
||||
}
|
||||
|
||||
func (p aDB) Items() *pogreb.ItemIterator {
|
||||
return p.intern.Items()
|
||||
func (p aDB) Items(_, _ int) ([]*Cert, error) {
|
||||
items := make([]*Cert, 0, p.intern.Count())
|
||||
iterator := p.intern.Items()
|
||||
for {
|
||||
key, resBytes, err := iterator.Next()
|
||||
if err != nil {
|
||||
if errors.Is(err, pogreb.ErrIterationDone) {
|
||||
break
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := &certificate.Resource{}
|
||||
if err := gob.NewDecoder(bytes.NewBuffer(resBytes)).Decode(res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cert, err := toCert(string(key), res)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
items = append(items, cert)
|
||||
}
|
||||
|
||||
return items, nil
|
||||
}
|
||||
|
||||
var _ CertDB = &aDB{}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue