some tests and major cleanup

This commit is contained in:
ston1th 2018-10-19 23:08:32 +02:00
commit 16671b3406
30 changed files with 192057 additions and 202431 deletions

View file

@ -3,13 +3,13 @@
package db
import (
"fmt"
"git.giftfish.de/ston1th/gowiki/pkg/cache"
"git.giftfish.de/ston1th/gowiki/pkg/core"
"git.giftfish.de/ston1th/gowiki/pkg/index"
"git.giftfish.de/ston1th/gowiki/pkg/render"
"git.giftfish.de/ston1th/gowiki/pkg/store"
"io"
"path/filepath"
)
const (
@ -24,24 +24,19 @@ You can customize it how you like.`
const blevePath = "bleve"
func dbErr(i interface{}) error {
return fmt.Errorf("db: %s", i)
}
type DB struct {
store store.Store
cache *cache.Cache
Index *index.Index
}
func New(datadir string) (db *DB, err error) {
func New(dir string) (db *DB, err error) {
db = &DB{cache: cache.NewCache()}
db.Index, err = index.NewIndex(datadir + "/" + blevePath)
db.store, err = store.NewBoltStore(filepath.Join(dir, storeFile), nil)
if err != nil {
return
}
db.store, err = store.NewBoltStore(storeFile, nil)
db.Index, err = index.NewIndex(filepath.Join(dir, blevePath))
if err != nil {
return
}