mirror of
https://github.com/restic/restic.git
synced 2024-12-24 00:37:28 +00:00
restore: count files in the same way as the stats command
This commit is contained in:
parent
e77002f841
commit
23a122a901
1 changed files with 19 additions and 5 deletions
|
@ -166,12 +166,14 @@ func (res *Restorer) restoreNodeTo(ctx context.Context, node *restic.Node, targe
|
||||||
err := node.CreateAt(ctx, target, res.repo)
|
err := node.CreateAt(ctx, target, res.repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
debug.Log("node.CreateAt(%s) error %v", target, err)
|
debug.Log("node.CreateAt(%s) error %v", target, err)
|
||||||
}
|
return err
|
||||||
if err == nil {
|
|
||||||
err = res.restoreNodeMetadataTo(node, target, location)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
if res.progress != nil {
|
||||||
|
res.progress.AddProgress(location, 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res.restoreNodeMetadataTo(node, target, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (res *Restorer) restoreNodeMetadataTo(node *restic.Node, target, location string) error {
|
func (res *Restorer) restoreNodeMetadataTo(node *restic.Node, target, location string) error {
|
||||||
|
@ -239,6 +241,9 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error {
|
||||||
_, err = res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{
|
_, err = res.traverseTree(ctx, dst, string(filepath.Separator), *res.sn.Tree, treeVisitor{
|
||||||
enterDir: func(node *restic.Node, target, location string) error {
|
enterDir: func(node *restic.Node, target, location string) error {
|
||||||
debug.Log("first pass, enterDir: mkdir %q, leaveDir should restore metadata", location)
|
debug.Log("first pass, enterDir: mkdir %q, leaveDir should restore metadata", location)
|
||||||
|
if res.progress != nil {
|
||||||
|
res.progress.AddFile(0)
|
||||||
|
}
|
||||||
// create dir with default permissions
|
// create dir with default permissions
|
||||||
// #leaveDir restores dir metadata after visiting all children
|
// #leaveDir restores dir metadata after visiting all children
|
||||||
return fs.MkdirAll(target, 0700)
|
return fs.MkdirAll(target, 0700)
|
||||||
|
@ -254,6 +259,9 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if node.Type != "file" {
|
if node.Type != "file" {
|
||||||
|
if res.progress != nil {
|
||||||
|
res.progress.AddFile(0)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +325,13 @@ func (res *Restorer) RestoreTo(ctx context.Context, dst string) error {
|
||||||
|
|
||||||
return res.restoreNodeMetadataTo(node, target, location)
|
return res.restoreNodeMetadataTo(node, target, location)
|
||||||
},
|
},
|
||||||
leaveDir: res.restoreNodeMetadataTo,
|
leaveDir: func(node *restic.Node, target, location string) error {
|
||||||
|
err := res.restoreNodeMetadataTo(node, target, location)
|
||||||
|
if err == nil && res.progress != nil {
|
||||||
|
res.progress.AddProgress(location, 0, 0)
|
||||||
|
}
|
||||||
|
return err
|
||||||
|
},
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue