Skip to content

Commit

Permalink
pkg/manager: tolerate empty crash directory
Browse files Browse the repository at this point in the history
It's okay if there have been no crashes yet.
  • Loading branch information
a-nogikh committed Oct 22, 2024
1 parent 95003e9 commit 27400f8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/manager/crash.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ func (cs *CrashStore) BugInfo(id string, full bool) (*BugInfo, error) {
func (cs *CrashStore) BugList() ([]*BugInfo, error) {
dirs, err := osutil.ListDir(filepath.Join(cs.BaseDir, "crashes"))
if err != nil {
if os.IsNotExist(err) {
// If there were no crashes, it's okay that there's no such folder.
return nil, nil
}
return nil, err
}
var ret []*BugInfo
Expand Down
9 changes: 9 additions & 0 deletions pkg/manager/crash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ func TestCrashList(t *testing.T) {
assert.Len(t, list[2].Crashes, 3)
}

func TestEmptyCrashList(t *testing.T) {
crashStore := &CrashStore{
BaseDir: t.TempDir(),
MaxCrashLogs: 10,
}
_, err := crashStore.BugList()
assert.NoError(t, err)
}

func TestMaxCrashLogs(t *testing.T) {
crashStore := &CrashStore{
BaseDir: t.TempDir(),
Expand Down

0 comments on commit 27400f8

Please sign in to comment.