mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 15:51:01 +00:00
skip error when open invalid db/frame name
This commit is contained in:
parent
3d8be89775
commit
641832ae10
2 changed files with 10 additions and 6 deletions
7
index.go
7
index.go
|
|
@ -80,9 +80,14 @@ func (i *Index) Open() error {
|
|||
|
||||
db, err := i.newDB(i.DBPath(filepath.Base(fi.Name())), filepath.Base(fi.Name()))
|
||||
if err != nil {
|
||||
return ErrName
|
||||
i.logger().Printf("ERROR opening database: %s, err=%s", fi.Name(), err)
|
||||
continue
|
||||
}
|
||||
if err := db.Open(); err != nil {
|
||||
if err == ErrName {
|
||||
i.logger().Printf("ERROR opening database: %s, err=%s", db.Name(), err)
|
||||
continue
|
||||
}
|
||||
return fmt.Errorf("open db: name=%s, err=%s", db.Name(), err)
|
||||
}
|
||||
i.dbs[db.Name()] = db
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ var (
|
|||
ErrDatabaseExists = errors.New("database already exists")
|
||||
ErrDatabaseNotFound = errors.New("database not found")
|
||||
|
||||
// ErrFrameRequired is returned when no frame is specified.
|
||||
ErrFrameRequired = errors.New("frame required")
|
||||
ErrFrameExists = errors.New("frame already exists")
|
||||
ErrFrameNotFound = errors.New("frame not found")
|
||||
|
||||
// ErrFrameRequired is returned when no frame is specified.
|
||||
ErrName = errors.New("name restricted to [a-z0-9_-]")
|
||||
ErrName = errors.New("invalid database or frame's name, must match [a-z0-9_-]")
|
||||
|
||||
// ErrFragmentNotFound is returned when a fragment does not exist.
|
||||
ErrFragmentNotFound = errors.New("fragment not found")
|
||||
|
|
@ -84,12 +84,11 @@ func decodeProfile(pb *internal.Profile) *Profile {
|
|||
// TimeFormat is the go-style time format used to parse string dates.
|
||||
const TimeFormat = "2006-01-02T15:04"
|
||||
|
||||
|
||||
// Restrict name using regex
|
||||
func ValidateName(name string) error {
|
||||
validName := nameRegexp.Match([]byte(name))
|
||||
if validName == false{
|
||||
if validName == false {
|
||||
return ErrName
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue