Store maps in new subdir "maps"

This commit is contained in:
Alexander Neumann
2014-11-23 22:26:01 +01:00
parent b1923063fe
commit 33ce4e33aa
9 changed files with 57 additions and 12 deletions

View File

@@ -6,6 +6,8 @@ import (
"errors"
"sort"
"sync"
"github.com/fd0/khepri/backend"
)
type BlobList struct {
@@ -21,6 +23,16 @@ func NewBlobList() *BlobList {
}
}
func LoadBlobList(ch *ContentHandler, id backend.ID) (*BlobList, error) {
bl := &BlobList{}
err := ch.LoadJSONRaw(backend.Map, id, bl)
if err != nil {
return nil, err
}
return bl, nil
}
func (bl *BlobList) find(blob Blob) (int, Blob, error) {
pos := sort.Search(len(bl.list), func(i int) bool {
return blob.ID.Compare(bl.list[i].ID) >= 0