Skip to content

Commit

Permalink
Merge branch 'nitro-v3.1.2' into celestia-v3.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferret-san committed Sep 3, 2024
2 parents 28da293 + 309340a commit ad4ae15
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions util/dbutil/dbutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package dbutil
import (
"errors"
"fmt"
"os"
"io/fs"
"regexp"

"github.com/cockroachdb/pebble"
Expand All @@ -22,13 +22,15 @@ func IsErrNotFound(err error) bool {
var pebbleNotExistErrorRegex = regexp.MustCompile("pebble: database .* does not exist")

func isPebbleNotExistError(err error) bool {
return pebbleNotExistErrorRegex.MatchString(err.Error())
return err != nil && pebbleNotExistErrorRegex.MatchString(err.Error())
}

func isLeveldbNotExistError(err error) bool {
return os.IsNotExist(err)
return errors.Is(err, fs.ErrNotExist)
}

// IsNotExistError returns true if the error is a "database not found" error.
// It must return false if err is nil.
func IsNotExistError(err error) bool {
return isLeveldbNotExistError(err) || isPebbleNotExistError(err)
}
Expand Down

0 comments on commit ad4ae15

Please sign in to comment.