Skip to content

Commit

Permalink
🐛 Do not parse hidden files like .gitkeep
Browse files Browse the repository at this point in the history
Signed-off-by: thatInfrastructureGuy <[email protected]>
  • Loading branch information
thatInfrastructureGuy committed Nov 12, 2023
1 parent 3c06303 commit 75aaaa0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion task.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
7 changes: 5 additions & 2 deletions taskset.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package dstask

import (
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 75aaaa0

Please sign in to comment.