From 0c7423d604594e32be2ef61069d15fb0e71512e3 Mon Sep 17 00:00:00 2001 From: ston1th Date: Mon, 2 Sep 2019 09:48:18 +0200 Subject: [PATCH] bug fix --- filter.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/filter.go b/filter.go index 7c6d442..4c3dc38 100644 --- a/filter.go +++ b/filter.go @@ -8,31 +8,37 @@ import ( "strings" ) +// Matcher is the matcher function type type Matcher func(path string) bool +// Filter defines an interface to filter paths or files type Filter interface { Filter(path string) error } +// ErrMacOSFilter error returned by the MacOSFilter var ErrMacOSFilter = errors.New("authdav: MacOS filter: access denied") +// MacOSFilter implements a filter for MacOS specific files type MacOSFilter struct { match []Matcher } +// NewMacOSFilter returns a new MacOSFilter func NewMacOSFilter() *MacOSFilter { return &MacOSFilter{ match: []Matcher{ - func(p string) { + func(p string) bool { return p == ".DS_Store" }, - func(p string) { + func(p string) bool { return strings.HasPrefix(p, "._") }, }, } } +// Filter implements the Filter interface func (f *MacOSFilter) Filter(path string) error { _, f := filepath.Split(path) for _, m := range f.match {