diff --git a/pkg/manager/crash.go b/pkg/manager/crash.go index 9be16e58e789..009ac2f150ba 100644 --- a/pkg/manager/crash.go +++ b/pkg/manager/crash.go @@ -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 diff --git a/pkg/manager/crash_test.go b/pkg/manager/crash_test.go index cce74284ad77..f017f017558d 100644 --- a/pkg/manager/crash_test.go +++ b/pkg/manager/crash_test.go @@ -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(),