mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
blobstorage: Improve mkdirall error (#13271)
This commit is contained in:
parent
c78d698d89
commit
a6b6a938de
@ -36,7 +36,7 @@ const (
|
||||
func NewBlobStorage(base string) (*BlobStorage, error) {
|
||||
base = path.Clean(base)
|
||||
if err := file.MkdirAll(base); err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("failed to create blob storage at %s: %w", base, err)
|
||||
}
|
||||
fs := afero.NewBasePathFs(afero.NewOsFs(), base)
|
||||
return &BlobStorage{fs: fs}, nil
|
||||
|
@ -2,6 +2,8 @@ package filesystem
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
@ -129,3 +131,14 @@ func TestBlobStorageDelete(t *testing.T) {
|
||||
// Deleting a non-existent root does not return an error.
|
||||
require.NoError(t, bs.Delete(bytesutil.ToBytes32([]byte{0x1})))
|
||||
}
|
||||
|
||||
func TestNewBlobStorage(t *testing.T) {
|
||||
_, err := NewBlobStorage(path.Join(t.TempDir(), "good"))
|
||||
require.NoError(t, err)
|
||||
|
||||
// If directory already exists with improper permissions, expect a wrapped err message.
|
||||
fp := path.Join(t.TempDir(), "bad")
|
||||
require.NoError(t, os.Mkdir(fp, 0777))
|
||||
_, err = NewBlobStorage(fp)
|
||||
require.ErrorContains(t, "failed to create blob storage", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user