From fb874ea7cccd3828930f8e952688a01d043e9968 Mon Sep 17 00:00:00 2001 From: Sebastian Schmidt Date: Thu, 1 Jan 2015 15:25:40 +0100 Subject: [PATCH] Allow nil 'Filter's for restorer Allow Filters to be nil and avoid joining the path again if no filter is used at all. --- restorer.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/restorer.go b/restorer.go index 87ddc0084..47c30fd85 100644 --- a/restorer.go +++ b/restorer.go @@ -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"))