devcam server: properly wipe mongo

Change-Id: Ib75a460a4be84e21affc662d45b3cf1e321b15bd
This commit is contained in:
mpl 2013-12-13 17:36:34 +01:00
parent b86e95caf4
commit 6d19d64b88
2 changed files with 5 additions and 20 deletions

View File

@ -276,9 +276,10 @@ func (c *serverCmd) setupIndexer() error {
"-dbtype=sqlite", "-dbtype=sqlite",
"-dbname="+c.env.m["CAMLI_DBNAME"]) "-dbname="+c.env.m["CAMLI_DBNAME"])
case c.mongo: case c.mongo:
// TODO(mpl): hack. add mongo support to dbinit instead. args = append(args,
c.env.Set("CAMLI_MONGO_WIPE", "true") "-dbtype=mongo",
fallthrough "-host=localhost",
"-dbname="+c.env.m["CAMLI_DBNAME"])
default: default:
return nil return nil
} }

View File

@ -19,13 +19,9 @@ limitations under the License.
package mongo package mongo
import ( import (
"os"
"strconv"
"camlistore.org/pkg/blobserver" "camlistore.org/pkg/blobserver"
"camlistore.org/pkg/index" "camlistore.org/pkg/index"
"camlistore.org/pkg/jsonconfig" "camlistore.org/pkg/jsonconfig"
"camlistore.org/pkg/sorted"
"camlistore.org/pkg/sorted/mongo" "camlistore.org/pkg/sorted/mongo"
) )
@ -40,24 +36,12 @@ func newFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (blobserver.Stor
if err != nil { if err != nil {
return nil, err return nil, err
} }
// TODO(mpl): hack. remove once dbinit supports mongo.
// https://camlistore-review.googlesource.com/1427
if wipe, _ := strconv.ParseBool(os.Getenv("CAMLI_MONGO_WIPE")); wipe {
wiper, ok := kv.(sorted.Wiper)
if !ok {
panic("mongo KeyValue not a Wiper")
}
err = wiper.Wipe()
if err != nil {
return nil, err
}
}
ix := index.New(kv) ix := index.New(kv)
sto, err := ld.GetStorage(blobPrefix) sto, err := ld.GetStorage(blobPrefix)
if err != nil { if err != nil {
return nil, err return nil, err
} }
ix.BlobSource = sto ix.BlobSource = sto
// Good enough, for now: // Good enough, for now: