mirror of
https://github.com/octoleo/restic.git
synced 2024-12-02 01:48:30 +00:00
Merge pull request #3566 from mathstuf/check-progress-output-stomping
check: wait for progress bar output
This commit is contained in:
commit
15cc3c0e23
@ -5,6 +5,7 @@ import (
|
|||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -252,7 +253,11 @@ func runCheck(opts CheckOptions, gopts GlobalOptions, args []string) error {
|
|||||||
|
|
||||||
Verbosef("check snapshots, trees and blobs\n")
|
Verbosef("check snapshots, trees and blobs\n")
|
||||||
errChan = make(chan error)
|
errChan = make(chan error)
|
||||||
|
var wg sync.WaitGroup
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
defer wg.Done()
|
||||||
bar := newProgressMax(!gopts.Quiet, 0, "snapshots")
|
bar := newProgressMax(!gopts.Quiet, 0, "snapshots")
|
||||||
defer bar.Done()
|
defer bar.Done()
|
||||||
chkr.Structure(gopts.ctx, bar, errChan)
|
chkr.Structure(gopts.ctx, bar, errChan)
|
||||||
@ -270,6 +275,11 @@ func runCheck(opts CheckOptions, gopts GlobalOptions, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Wait for the progress bar to be complete before printing more below.
|
||||||
|
// Must happen after `errChan` is read from in the above loop to avoid
|
||||||
|
// deadlocking in the case of errors.
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
if opts.CheckUnused {
|
if opts.CheckUnused {
|
||||||
for _, id := range chkr.UnusedBlobs(gopts.ctx) {
|
for _, id := range chkr.UnusedBlobs(gopts.ctx) {
|
||||||
Verbosef("unused blob %v\n", id)
|
Verbosef("unused blob %v\n", id)
|
||||||
|
Loading…
Reference in New Issue
Block a user