more cleanup
This commit is contained in:
parent
16671b3406
commit
78680de687
6 changed files with 200491 additions and 189802 deletions
|
|
@ -52,9 +52,6 @@ func New(dir string) (db *DB, err error) {
|
|||
}
|
||||
|
||||
_, err = db.CreatePage(core.IndexPage, core.WikiSection, welcome, defUser, core.Public)
|
||||
if err != nil && err != store.ErrKeyNotFound {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ var (
|
|||
errPermissionDenied = errors.New("db: permission denied")
|
||||
errInvalidPermission = errors.New("db: invalid permission")
|
||||
errPrivateWikiPage = errors.New("db: private wiki pages are not allowed")
|
||||
errNonPublicIndexPage = errors.New("db: internal/private index page is not allowed")
|
||||
errDeleteIndexPage = errors.New("db: index page can not be deleted")
|
||||
)
|
||||
|
||||
|
|
@ -77,7 +78,9 @@ func (db *DB) CreatePage(title, section, markdown, username string, p core.Permi
|
|||
}
|
||||
}
|
||||
st := render.StoreTitle(section, render.Title(title))
|
||||
if _, err = db.getPage(st, username); err != nil && err != store.ErrKeyNotFound {
|
||||
_, err = db.getPage(st, username)
|
||||
//if err == nil || (err != nil && err != store.ErrKeyNotFound) {
|
||||
if err != store.ErrKeyNotFound {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +116,11 @@ func (db *DB) UpdatePage(title, section, markdown, username string, p core.Permi
|
|||
err = errPrivateWikiPage
|
||||
return
|
||||
}
|
||||
if section == core.WikiSection && title == core.IndexPage &&
|
||||
(p == core.Internal || p == core.Private) {
|
||||
err = errNonPublicIndexPage
|
||||
return
|
||||
}
|
||||
st := render.StoreTitle(section, title)
|
||||
page, err := db.getPage(st, username)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ var (
|
|||
debug = false
|
||||
)
|
||||
|
||||
func InitLogger(dir, file string, debug bool) {
|
||||
debug = debug
|
||||
func InitLogger(dir, file string, d bool) {
|
||||
debug = d
|
||||
if file == "-" {
|
||||
return
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ func Fatal(v ...interface{}) {
|
|||
|
||||
func Debug(v ...interface{}) {
|
||||
if debug {
|
||||
log.Println(append([]interface{}{"debug:"}, v...))
|
||||
log.Println(append([]interface{}{"debug:"}, v...)...)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,22 +18,21 @@ type BoltStore struct {
|
|||
db *bolt.DB
|
||||
}
|
||||
|
||||
func NewBoltStore(file string, m Marshaler) (bs *BoltStore, err error) {
|
||||
func NewBoltStore(file string, m Marshaler) (Store, error) {
|
||||
if m == nil {
|
||||
m = NewGOB()
|
||||
}
|
||||
db, err := bolt.Open(file, fileMode, nil)
|
||||
if err != nil {
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
if err = db.Update(func(tx *bolt.Tx) (err error) {
|
||||
_, err = tx.CreateBucketIfNotExists([]byte(defaultBoltBucket))
|
||||
return
|
||||
}); err != nil {
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
bs = &BoltStore{m, db}
|
||||
return
|
||||
return &BoltStore{m, db}, nil
|
||||
}
|
||||
|
||||
type dump struct {
|
||||
|
|
|
|||
62
vendor/github.com/blevesearch/segment/segment_words.go
generated
vendored
62
vendor/github.com/blevesearch/segment/segment_words.go
generated
vendored
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
//line segment_words.rl:1
|
||||
// Copyright (c) 2015 Couchbase, Inc.
|
||||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
||||
|
|
@ -31,7 +30,6 @@ const (
|
|||
Ideo
|
||||
)
|
||||
|
||||
|
||||
//line segment_words.go:36
|
||||
var _s_key_offsets []uint16 = []uint16{
|
||||
0, 1, 3, 5, 7, 10, 15, 20,
|
||||
|
|
@ -18539,10 +18537,8 @@ const s_error int = -1
|
|||
|
||||
const s_en_main int = 4862
|
||||
|
||||
|
||||
//line segment_words.rl:35
|
||||
|
||||
|
||||
func segmentWords(data []byte, maxTokens int, atEOF bool, val [][]byte, types []int) ([][]byte, []int, int, error) {
|
||||
cs, p, pe := 0, 0, len(data)
|
||||
cap := maxTokens
|
||||
|
|
@ -18593,7 +18589,6 @@ _resume:
|
|||
//line NONE:1
|
||||
ts = p
|
||||
|
||||
|
||||
//line segment_words.go:18598
|
||||
}
|
||||
|
||||
|
|
@ -18664,7 +18659,6 @@ _eof_trans:
|
|||
|
||||
endPos = p
|
||||
|
||||
|
||||
case 34:
|
||||
//line segment_words.rl:76
|
||||
te = p
|
||||
|
|
@ -19067,7 +19061,8 @@ p = (te) - 1
|
|||
//line NONE:1
|
||||
switch act {
|
||||
case 1:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
if !atEOF {
|
||||
return val, types, totalConsumed, nil
|
||||
|
|
@ -19081,7 +19076,8 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
case 2:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
if endPos+1 == pe && !atEOF {
|
||||
return val, types, totalConsumed, nil
|
||||
|
|
@ -19097,7 +19093,8 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
case 3:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
if endPos+1 == pe && !atEOF {
|
||||
return val, types, totalConsumed, nil
|
||||
|
|
@ -19113,7 +19110,8 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
case 4:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
if !atEOF {
|
||||
return val, types, totalConsumed, nil
|
||||
|
|
@ -19126,7 +19124,8 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
case 5:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
if endPos+1 == pe && !atEOF {
|
||||
return val, types, totalConsumed, nil
|
||||
|
|
@ -19142,7 +19141,8 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
case 7:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
lastPos := startPos
|
||||
for lastPos <= endPos {
|
||||
|
|
@ -19166,7 +19166,8 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
case 12:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
lastPos := startPos
|
||||
for lastPos <= endPos {
|
||||
|
|
@ -19190,7 +19191,8 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
case 13:
|
||||
{p = (te) - 1
|
||||
{
|
||||
p = (te) - 1
|
||||
|
||||
lastPos := startPos
|
||||
for lastPos <= endPos {
|
||||
|
|
@ -19215,7 +19217,6 @@ p = (te) - 1
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
case 28:
|
||||
//line segment_words.rl:68
|
||||
|
||||
|
|
@ -19225,7 +19226,6 @@ p = (te) - 1
|
|||
|
||||
endPos = p
|
||||
|
||||
|
||||
case 33:
|
||||
//line segment_words.rl:72
|
||||
|
||||
|
|
@ -19294,7 +19294,6 @@ te = p+1
|
|||
|
||||
endPos = p
|
||||
|
||||
|
||||
case 26:
|
||||
//line segment_words.rl:68
|
||||
|
||||
|
|
@ -19372,7 +19371,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:76
|
||||
act = 1;
|
||||
act = 1
|
||||
|
||||
case 11:
|
||||
//line NONE:1
|
||||
|
|
@ -19383,7 +19382,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:89
|
||||
act = 2;
|
||||
act = 2
|
||||
|
||||
case 16:
|
||||
//line NONE:1
|
||||
|
|
@ -19394,7 +19393,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:104
|
||||
act = 3;
|
||||
act = 3
|
||||
|
||||
case 6:
|
||||
//line NONE:1
|
||||
|
|
@ -19405,7 +19404,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:119
|
||||
act = 4;
|
||||
act = 4
|
||||
|
||||
case 14:
|
||||
//line NONE:1
|
||||
|
|
@ -19416,7 +19415,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:131
|
||||
act = 5;
|
||||
act = 5
|
||||
|
||||
case 20:
|
||||
//line NONE:1
|
||||
|
|
@ -19427,7 +19426,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:161
|
||||
act = 7;
|
||||
act = 7
|
||||
|
||||
case 9:
|
||||
//line NONE:1
|
||||
|
|
@ -19438,7 +19437,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:161
|
||||
act = 12;
|
||||
act = 12
|
||||
|
||||
case 2:
|
||||
//line NONE:1
|
||||
|
|
@ -19449,7 +19448,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:161
|
||||
act = 13;
|
||||
act = 13
|
||||
|
||||
case 29:
|
||||
//line NONE:1
|
||||
|
|
@ -19464,7 +19463,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:76
|
||||
act = 1;
|
||||
act = 1
|
||||
|
||||
case 30:
|
||||
//line NONE:1
|
||||
|
|
@ -19479,7 +19478,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:119
|
||||
act = 4;
|
||||
act = 4
|
||||
|
||||
case 25:
|
||||
//line NONE:1
|
||||
|
|
@ -19494,7 +19493,7 @@ te = p+1
|
|||
endPos = p
|
||||
|
||||
//line segment_words.rl:161
|
||||
act = 13;
|
||||
act = 13
|
||||
|
||||
//line segment_words.go:19500
|
||||
}
|
||||
|
|
@ -19505,14 +19504,15 @@ _again:
|
|||
//line NONE:1
|
||||
ts = 0
|
||||
|
||||
|
||||
//line segment_words.go:19510
|
||||
}
|
||||
|
||||
if p++; p != pe {
|
||||
goto _resume
|
||||
}
|
||||
_test_eof: {}
|
||||
_test_eof:
|
||||
{
|
||||
}
|
||||
if p == eof {
|
||||
if _s_eof_trans[cs] > 0 {
|
||||
_trans = int(_s_eof_trans[cs] - 1)
|
||||
|
|
@ -19524,7 +19524,6 @@ ts = 0
|
|||
|
||||
startPos = p
|
||||
|
||||
|
||||
//line segment_words.go:19529
|
||||
}
|
||||
}
|
||||
|
|
@ -19533,7 +19532,6 @@ ts = 0
|
|||
|
||||
//line segment_words.rl:278
|
||||
|
||||
|
||||
if cs < s_first_final {
|
||||
return val, types, totalConsumed, ParseError
|
||||
}
|
||||
|
|
|
|||
22285
vendor/github.com/blevesearch/segment/segment_words_prod.go
generated
vendored
22285
vendor/github.com/blevesearch/segment/segment_words_prod.go
generated
vendored
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue