Skip to content

Commit

Permalink
prune: Add progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
fd0 committed Aug 6, 2016
1 parent 951f67d commit 5fed210
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cmds/restic/cmd_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ func (cmd CmdPrune) Execute(args []string) error {
ch := make(chan worker.Job)
go repository.ListAllPacks(repo, ch, done)

bar := pb.New(len(packs))
bar.Width = 70
bar.Start()
for job := range ch {
packID := job.Data.(backend.ID)
if job.Error != nil {
Expand All @@ -92,7 +95,9 @@ func (cmd CmdPrune) Execute(args []string) error {
duplicateBytes += int(pb.Length)
}
}
bar.Increment()
}
bar.Finish()

cmd.global.Verbosef("processed %d blobs: %d duplicate blobs, %d duplicate bytes\n",
stats.blobs, duplicateBlobs, duplicateBytes)
Expand All @@ -109,9 +114,9 @@ func (cmd CmdPrune) Execute(args []string) error {

usedBlobs := pack.NewBlobSet()
seenBlobs := pack.NewBlobSet()
pb := pb.New(len(snapshots))
pb.Width = 70
pb.Start()
bar = pb.New(len(snapshots))
bar.Width = 70
bar.Start()
for _, sn := range snapshots {
debug.Log("CmdPrune.Execute", "process snapshot %v", sn.ID().Str())

Expand All @@ -121,9 +126,9 @@ func (cmd CmdPrune) Execute(args []string) error {
}

debug.Log("CmdPrune.Execute", "found %v blobs for snapshot %v", sn.ID().Str())
pb.Increment()
bar.Increment()
}
pb.Finish()
bar.Finish()

cmd.global.Verbosef("found %d of %d data blobs still in use\n", len(usedBlobs), stats.blobs)

Expand Down

0 comments on commit 5fed210

Please sign in to comment.