2015-10-25 16:24:52 +00:00
|
|
|
package main
|
|
|
|
|
2016-05-11 20:30:32 +00:00
|
|
|
import "restic/repository"
|
2015-10-25 16:24:52 +00:00
|
|
|
|
|
|
|
type CmdRebuildIndex struct {
|
|
|
|
global *GlobalOptions
|
|
|
|
|
|
|
|
repo *repository.Repository
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
_, err := parser.AddCommand("rebuild-index",
|
|
|
|
"rebuild the index",
|
|
|
|
"The rebuild-index command builds a new index",
|
|
|
|
&CmdRebuildIndex{global: &globalOpts})
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (cmd CmdRebuildIndex) Execute(args []string) error {
|
|
|
|
repo, err := cmd.global.OpenRepository()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
cmd.repo = repo
|
|
|
|
|
|
|
|
lock, err := lockRepoExclusive(repo)
|
|
|
|
defer unlockRepo(lock)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2016-05-11 20:30:32 +00:00
|
|
|
return repository.RebuildIndex(repo)
|
2015-10-25 16:24:52 +00:00
|
|
|
}
|