Browse Source

fixed because of leveldb's change

pull/103/head
Lunny Xiao 11 years ago
parent
commit
4d0128b057
  1. 15
      cmd/serve.go

15
cmd/serve.go

@ -15,12 +15,11 @@
package cmd package cmd
import ( import (
serrors "errors" "errors"
"fmt" "fmt"
"github.com/Unknwon/com" "github.com/Unknwon/com"
"github.com/gpmgo/gopm/doc" "github.com/gpmgo/gopm/doc"
"github.com/syndtr/goleveldb/leveldb" "github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/opt" "github.com/syndtr/goleveldb/leveldb/opt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -184,7 +183,7 @@ func saveNode(nod *doc.Node) error {
if resp.StatusCode == 200 { if resp.StatusCode == 200 {
return nil return nil
} }
return serrors.New("save node failed with " + resp.Status) return errors.New("save node failed with " + resp.Status)
} }
// for inetrnal of serve to add node to db // for inetrnal of serve to add node to db
@ -192,7 +191,7 @@ func addNode(nod *doc.Node) error {
batch := new(leveldb.Batch) batch := new(leveldb.Batch)
strLastId, err := dbGet("lastId") strLastId, err := dbGet("lastId")
if err != nil { if err != nil {
if err == errors.ErrNotFound { if err == leveldb.ErrNotFound {
strLastId = "0" strLastId = "0"
err = batchPut(batch, "lastId", strLastId) err = batchPut(batch, "lastId", strLastId)
} else { } else {
@ -212,7 +211,7 @@ func addNode(nod *doc.Node) error {
id, err := dbGet(nodKey) id, err := dbGet(nodKey)
if err != nil { if err != nil {
if err == errors.ErrNotFound { if err == leveldb.ErrNotFound {
id = fmt.Sprintf("%v", lastId+1) id = fmt.Sprintf("%v", lastId+1)
err = batchPut(batch, "lastId", id) err = batchPut(batch, "lastId", id)
if err == nil { if err == nil {
@ -234,7 +233,7 @@ func addNode(nod *doc.Node) error {
// save totals // save totals
total, err := dbGet("total") total, err := dbGet("total")
if err != nil { if err != nil {
if err == errors.ErrNotFound { if err == leveldb.ErrNotFound {
total = "1" total = "1"
} else { } else {
return err return err
@ -260,9 +259,9 @@ func addNode(nod *doc.Node) error {
// save vers // save vers
vers, err := dbGet("ver:" + id) vers, err := dbGet("ver:" + id)
needSplit := (err == errors.ErrNotFound) needSplit := (err == leveldb.ErrNotFound)
if err != nil { if err != nil {
if err != errors.ErrNotFound { if err != leveldb.ErrNotFound {
return err return err
} }
} else { } else {

Loading…
Cancel
Save