/
recover.go
57 lines (46 loc) · 1.45 KB
/
recover.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
PRLPKS - OpenPGP Synchronized Key Server with Deletion
Copyright (c) 2014 Pruthvirajsinh Rajendrasinh Chauhan
PRLPKS is based heavily on hockeypuck(https://launchpad.net/hockeypuck) by Casey Marshall, copyright 2013(GNU GPL v3).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
// prlpks is an OpenPGP keyserver.
package main
import (
"log"
"launchpad.net/gnuflag"
. "github.com/pruthvirajsinh/prlpks"
"github.com/pruthvirajsinh/prlpks/openpgp"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/storage"
)
type recoverCmd struct {
configuredCmd
}
func (rc *recoverCmd) Name() string { return "recover" }
func (rc *recoverCmd) Desc() string { return "Recover prefix tree" }
func newRecoverCmd() *recoverCmd {
cmd := new(recoverCmd)
flags := gnuflag.NewFlagSet(cmd.Name(), gnuflag.ExitOnError)
flags.StringVar(&cmd.configPath, "config", "", "prlpks configuration file")
cmd.flags = flags
return cmd
}
func (ec *recoverCmd) Main() {
ec.configuredCmd.Main()
InitLog()
path := openpgp.Config().Settings.TomlTree.Get("symflux.recon.leveldb.path").(string)
stor, err := storage.OpenFile(path)
if err != nil {
die(err)
}
log.Println("database storage opened, recovering...")
db, err := leveldb.Recover(stor, nil)
if err != nil {
die(err)
}
log.Println("recovery complete")
db.Close()
}