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:
Sebastian Schmidt 2015-01-01 15:25:40 +01:00
parent 10b99e53e4
commit fb874ea7cc
1 changed files with 2 additions and 3 deletions

View File

@ -36,8 +36,6 @@ func NewRestorer(s Server, snid backend.ID) (*Restorer, error) {
// abort on all errors
r.Error = func(string, *Node, error) error { return err }
// allow all files
r.Filter = func(string, string, *Node) bool { return true }
return r, nil
}
@ -52,7 +50,8 @@ func (res *Restorer) to(dst string, dir string, tree_id backend.ID) error {
for _, node := range tree {
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)
if err != nil {
err = res.Error(dstpath, node, arrar.Annotate(err, "create node"))