From 75aaaa0e89785588f5b075265aba694d3914ca05 Mon Sep 17 00:00:00 2001 From: thatInfrastructureGuy Date: Mon, 17 Jul 2023 16:36:28 -0700 Subject: [PATCH] :bug: Do not parse hidden files like .gitkeep Signed-off-by: thatInfrastructureGuy --- task.go | 2 +- taskset.go | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/task.go b/task.go index dff30f44..c833e1b4 100644 --- a/task.go +++ b/task.go @@ -102,7 +102,7 @@ func (t Task) Equals(t2 Task) bool { // Unmarshal a Task from disk. We explicitly pass status, because the caller // already knows the status, and can override the status declared in yaml. -func unmarshalTask(path string, finfo os.FileInfo, ids IdsMap, status string) (Task, error) { +func unmarshalTask(path string, finfo os.DirEntry, ids IdsMap, status string) (Task, error) { if len(finfo.Name()) != TASK_FILENAME_LEN { return Task{}, fmt.Errorf("filename does not encode UUID %s (wrong length)", finfo.Name()) } diff --git a/taskset.go b/taskset.go index ab15e128..d5f4e361 100644 --- a/taskset.go +++ b/taskset.go @@ -4,7 +4,6 @@ package dstask import ( "fmt" - "io/ioutil" "log" "os" "path/filepath" @@ -69,7 +68,7 @@ func LoadTaskSet(repoPath, idsFilePath string, includeResolved bool) (*TaskSet, for _, status := range statuses { dir := filepath.Join(repoPath, status) - files, err := ioutil.ReadDir(dir) + files, err := os.ReadDir(dir) if err != nil { if os.IsNotExist(err) { // Continuing here is necessary, because we do not guarantee @@ -79,6 +78,10 @@ func LoadTaskSet(repoPath, idsFilePath string, includeResolved bool) (*TaskSet, return nil, err } for _, finfo := range files { + // Discard hidden files like .gitkeep + if strings.HasPrefix(finfo.Name(), ".") { + continue + } path := filepath.Join(dir, finfo.Name()) t, err := unmarshalTask(path, finfo, ids, status) if err != nil {