mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-07 22:54:17 -05:00
also ignore errors from readdirnames (#15947)
* also ignore errors from readdirnames * test case for empty blobs dir --------- Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
2
changelog/kasey_ignore-readdir-errors.md
Normal file
2
changelog/kasey_ignore-readdir-errors.md
Normal file
@@ -0,0 +1,2 @@
|
||||
### Ignored
|
||||
- Fix bug with layout detection when readdirnames returns io.EOF.
|
||||
@@ -2,6 +2,7 @@ package storage
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"slices"
|
||||
@@ -139,6 +140,10 @@ func detectLayout(dir string, c stringFlagGetter) (string, error) {
|
||||
// amount of wiggle room to be confident that we'll likely see a by-root director if one exists.
|
||||
entries, err := base.Readdirnames(16)
|
||||
if err != nil {
|
||||
// We can get this error if the directory exists and is empty
|
||||
if errors.Is(err, io.EOF) {
|
||||
return filesystem.LayoutNameByEpoch, nil
|
||||
}
|
||||
return "", errors.Wrap(err, "reading blob storage directory")
|
||||
}
|
||||
for _, entry := range entries {
|
||||
|
||||
@@ -192,6 +192,13 @@ func TestDetectLayout(t *testing.T) {
|
||||
},
|
||||
expectedErr: syscall.ENOTDIR,
|
||||
},
|
||||
{
|
||||
name: "empty blobs dir",
|
||||
setup: func(t *testing.T, dir string) {
|
||||
require.NoError(t, os.MkdirAll(dir, 0o755))
|
||||
},
|
||||
expected: filesystem.LayoutNameByEpoch,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
|
||||
Reference in New Issue
Block a user