mirror of https://github.com/restic/restic.git
Allow nil 'Filter's for restorer
Allow Filters to be nil and avoid joining the path again if no filter is used at all.
This commit is contained in:
parent
10b99e53e4
commit
fb874ea7cc
|
@ -36,8 +36,6 @@ func NewRestorer(s Server, snid backend.ID) (*Restorer, error) {
|
||||||
|
|
||||||
// abort on all errors
|
// abort on all errors
|
||||||
r.Error = func(string, *Node, error) error { return err }
|
r.Error = func(string, *Node, error) error { return err }
|
||||||
// allow all files
|
|
||||||
r.Filter = func(string, string, *Node) bool { return true }
|
|
||||||
|
|
||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
@ -52,7 +50,8 @@ func (res *Restorer) to(dst string, dir string, tree_id backend.ID) error {
|
||||||
for _, node := range tree {
|
for _, node := range tree {
|
||||||
dstpath := filepath.Join(dst, dir, node.Name)
|
dstpath := filepath.Join(dst, dir, node.Name)
|
||||||
|
|
||||||
if res.Filter(filepath.Join(res.sn.Dir, dir, node.Name), dstpath, node) {
|
if res.Filter == nil ||
|
||||||
|
res.Filter(filepath.Join(res.sn.Dir, dir, node.Name), dstpath, node) {
|
||||||
err := node.CreateAt(res.ch, dstpath)
|
err := node.CreateAt(res.ch, dstpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = res.Error(dstpath, node, arrar.Annotate(err, "create node"))
|
err = res.Error(dstpath, node, arrar.Annotate(err, "create node"))
|
||||||
|
|
Loading…
Reference in New Issue