1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2025-03-16 00:00:05 +01:00

Implement progress bar for scans as well

* Remote repositories may take a while to scan, so give the user a little bit of feedback while we do so
This commit is contained in:
Seb Patane 2016-11-14 22:51:29 +10:00
parent d8377140f1
commit 465d4297b9
2 changed files with 12 additions and 4 deletions

View file

@ -136,7 +136,7 @@ func runRestore(opts RestoreOptions, gopts GlobalOptions, args []string) error {
Verbosef("restoring %s to %s\n", res.Snapshot(), opts.Target)
stat, err := res.Scan()
stat, err := res.Scan(newScanProgress(gopts))
if err != nil {
return err
}

View file

@ -41,16 +41,24 @@ func NewRestorer(repo Repository, id ID) (*Restorer, error) {
}
// Scan traverses the directories/files to be restored to collect restic.Stat information
func (res *Restorer) Scan() (Stat, error) {
func (res *Restorer) Scan(p *Progress) (Stat, error) {
p.Start()
defer p.Done()
var stat Stat
err := res.walk("", *res.sn.Tree, func(node *Node, dir string) error {
s := Stat{}
if node.Type == "dir" {
stat.Add(Stat{Dirs: 1})
s.Dirs++
} else {
stat.Add(Stat{Files: 1, Bytes: node.Size})
s.Files++
s.Bytes += node.Size
}
p.Report(s)
stat.Add(s)
return nil
})