From 919359f26fda1a1fe459f2fb207bf51a754e3b7b Mon Sep 17 00:00:00 2001 From: Grzegorz Dlugoszewski Date: Mon, 8 Jun 2020 20:01:13 +0200 Subject: [PATCH] Skip walking directories we don't have permissions to access --- path/list.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/path/list.go b/path/list.go index 60df3cb..0b5d219 100644 --- a/path/list.go +++ b/path/list.go @@ -7,6 +7,7 @@ import ( "os" "sort" "strings" + "syscall" "github.com/karrick/godirwalk" "github.com/pkg/errors" @@ -56,7 +57,9 @@ func WalkCb(path string, ent *godirwalk.Dirent) error { } func ErrorCb(_ string, err error) godirwalk.ErrorAction { - if errors.Is(err, skipNode) { + // Skip .git directory and directories we don't have permissions to access + // TODO: Will syscall.EACCES work on windows? + if errors.Is(err, skipNode) || errors.Is(err, syscall.EACCES) { return godirwalk.SkipNode } return godirwalk.Halt