2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-10 04:42:21 +00:00

Rebuild index at the end of prune

This commit is contained in:
Alexander Neumann 2016-08-15 20:46:24 +02:00
parent 1bb2d59e38
commit 29bb845f0e

View File

@ -175,11 +175,27 @@ func (cmd CmdPrune) Execute(args []string) error {
cmd.global.Verbosef("creating new index\n")
err = repository.RebuildIndex(repo)
idx, err = index.New(repo)
if err != nil {
return err
}
id, err := idx.Save(repo)
if err != nil {
return err
}
cmd.global.Verbosef("saved new index as %v\n", id.Str())
for oldIndex := range repo.List(backend.Index, done) {
if id.Equal(oldIndex) {
continue
}
err := repo.Backend().Remove(backend.Index, oldIndex.String())
if err != nil {
fmt.Fprintf(os.Stderr, "unable to remove index %v: %v\n", oldIndex.Str(), err)
}
}
cmd.global.Verbosef("done\n")
return nil
}