Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JkLondon committed Nov 4, 2024
1 parent 2466c93 commit 7f6b3fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
20 changes: 5 additions & 15 deletions erigon-lib/common/customfs/customfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ func underlyingErrorIs(err, target error) bool {
// underlyingError only unwraps the specific error-wrapping types
// that it historically did, not all errors implementing Unwrap().
err = underlyingError(err)
if err == target {
if errors.Is(err, target) {
return true
}
// To preserve prior behavior, only examine syscall errors.
e, ok := err.(syscallErrorType)
var e syscallErrorType
ok := errors.As(err, &e)
return ok && e.Is(target)
}

// underlyingError returns the underlying error for known os error types.
func underlyingError(err error) error {
switch err := err.(type) {
switch err := err.(type) { //nolint
case *os.PathError:
return err.Err
case *os.LinkError:
Expand Down Expand Up @@ -80,21 +81,10 @@ func genericReadFrom(f *CustomFile, r io.Reader) (int64, error) {
return io.Copy(fileWithoutReadFrom{CustomFile: f}, r)
}

// noReadFrom can be embedded alongside another type to
// hide the ReadFrom method of that other type.
type noReadFrom struct{}

// ReadFrom hides another ReadFrom method.
// It should never be called.
func (noReadFrom) ReadFrom(io.Reader) (int64, error) {
panic("can't happen")
}

// fileWithoutReadFrom implements all the methods of *File other
// than ReadFrom. This is used to permit ReadFrom to call io.Copy
// without leading to a recursive call to ReadFrom.
type fileWithoutReadFrom struct {
noReadFrom
*CustomFile
}

Expand Down Expand Up @@ -254,7 +244,7 @@ func (fs *CustomFileSystem) ReadFile(name string) ([]byte, error) {
n, err := f.Read(data[len(data):cap(data)])
data = data[:len(data)+n]
if err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
err = nil
}
return data, err
Expand Down
1 change: 1 addition & 0 deletions erigon-lib/state/aggregator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ func testDbAndAggregatorv3(t *testing.T, aggStep uint64) (kv.RwDB, *Aggregator)
err := customfs.CFS.RemoveAll(tmpName)
require.NoError(err)
err = os.RemoveAll(tmpName)
require.NoError(err)
})
logger := log.New()
db := mdbx.NewMDBX(logger).InMem(dirs.Chaindata).GrowthStep(32 * datasize.MB).MapSize(2 * datasize.GB).WithTableCfg(func(defaultBuckets kv.TableCfg) kv.TableCfg {
Expand Down

0 comments on commit 7f6b3fa

Please sign in to comment.