mirror of https://github.com/perkeep/perkeep.git
devcam server: properly wipe mongo
Change-Id: Ib75a460a4be84e21affc662d45b3cf1e321b15bd
This commit is contained in:
parent
b86e95caf4
commit
6d19d64b88
|
@ -276,9 +276,10 @@ func (c *serverCmd) setupIndexer() error {
|
|||
"-dbtype=sqlite",
|
||||
"-dbname="+c.env.m["CAMLI_DBNAME"])
|
||||
case c.mongo:
|
||||
// TODO(mpl): hack. add mongo support to dbinit instead.
|
||||
c.env.Set("CAMLI_MONGO_WIPE", "true")
|
||||
fallthrough
|
||||
args = append(args,
|
||||
"-dbtype=mongo",
|
||||
"-host=localhost",
|
||||
"-dbname="+c.env.m["CAMLI_DBNAME"])
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -19,13 +19,9 @@ limitations under the License.
|
|||
package mongo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"camlistore.org/pkg/blobserver"
|
||||
"camlistore.org/pkg/index"
|
||||
"camlistore.org/pkg/jsonconfig"
|
||||
"camlistore.org/pkg/sorted"
|
||||
"camlistore.org/pkg/sorted/mongo"
|
||||
)
|
||||
|
||||
|
@ -40,24 +36,12 @@ func newFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (blobserver.Stor
|
|||
if err != nil {
|
||||
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)
|
||||
sto, err := ld.GetStorage(blobPrefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ix.BlobSource = sto
|
||||
|
||||
// Good enough, for now:
|
||||
|
|
Loading…
Reference in New Issue