diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-10-22 11:21:48 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2024-10-22 12:59:10 +0000 |
| commit | 27400f8cb0a0f9ad9e5357425baf0a2c3373e54e (patch) | |
| tree | 5ef8aab2487704c430184b29a2690edc28cf0ef4 /pkg/manager | |
| parent | 95003e97d969ca5c4637325fdcb4f4b5757b5673 (diff) | |
pkg/manager: tolerate empty crash directory
It's okay if there have been no crashes yet.
Diffstat (limited to 'pkg/manager')
| -rw-r--r-- | pkg/manager/crash.go | 4 | ||||
| -rw-r--r-- | pkg/manager/crash_test.go | 9 |
2 files changed, 13 insertions, 0 deletions
diff --git a/pkg/manager/crash.go b/pkg/manager/crash.go index 9be16e58e..009ac2f15 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 cce74284a..f017f0175 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(), |
