mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 14:56:29 +00:00
Rebuild index at the end of prune
This commit is contained in:
parent
1bb2d59e38
commit
29bb845f0e
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user