Skip to content

Commit

Permalink
Fix bad diag result on dotfiles in log dirs
Browse files Browse the repository at this point in the history
The diagnostics code was producing a diag.Result that can't be unpacked
when a log directory contained files named like `.placeholder`.
  • Loading branch information
Ivan Shvedunov committed Aug 27, 2018
1 parent 89b947f commit 973cb7b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions pkg/diag/diag.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ func (s *LogDirSource) DiagnosticInfo() (Result, error) {
continue
}
name := fi.Name()
if strings.HasPrefix(name, ".") {
continue
}
ext := filepath.Ext(name)
cur := Result{
Name: name,
Expand Down
6 changes: 4 additions & 2 deletions pkg/diag/diag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ func setupLogDir(t *testing.T, baseDir string) string {
t.Fatalf("MkdirAll(): %v", err)
}
for name, contents := range map[string]string{
"log1.txt": "log1 contents",
"log2.txt": "log2 contents",
"log1.txt": "log1 contents",
"log2.txt": "log2 contents",
".placeholder": "ignored file",
".place.holder": "another ignored file",
} {
if err := ioutil.WriteFile(filepath.Join(logDir, name), []byte(contents), 0777); err != nil {
t.Fatalf("WriteFile(): %v", err)
Expand Down

0 comments on commit 973cb7b

Please sign in to comment.