add . before meta frame

This commit is contained in:
Linh Vo 2017-03-07 15:37:00 -06:00 committed by Travis
parent 9908002863
commit 920b9d01e2
3 changed files with 7 additions and 6 deletions

7
db.go
View file

@ -60,7 +60,7 @@ func NewDB(path, name string) (*DB, error) {
frames: make(map[string]*Frame),
remoteMaxSlice: 0,
profileAttrStore: NewAttrStore(filepath.Join(path, "data")),
profileAttrStore: NewAttrStore(filepath.Join(path, ".data")),
columnLabel: DefaultColumnLabel,
@ -165,7 +165,7 @@ func (db *DB) loadMeta() error {
var pb internal.DB
// Read data from meta file.
buf, err := ioutil.ReadFile(filepath.Join(db.path, "meta"))
buf, err := ioutil.ReadFile(filepath.Join(db.path, ".meta"))
if os.IsNotExist(err) {
db.timeQuantum = ""
db.columnLabel = DefaultColumnLabel
@ -188,6 +188,7 @@ func (db *DB) loadMeta() error {
// saveMeta writes meta data for the database.
func (db *DB) saveMeta() error {
// Marshal metadata.
buf, err := proto.Marshal(&internal.DB{
TimeQuantum: string(db.timeQuantum),
ColumnLabel: db.columnLabel,
@ -197,7 +198,7 @@ func (db *DB) saveMeta() error {
}
// Write to meta file.
if err := ioutil.WriteFile(filepath.Join(db.path, "meta"), buf, 0666); err != nil {
if err := ioutil.WriteFile(filepath.Join(db.path, ".meta"), buf, 0666); err != nil {
return err
}

View file

@ -106,13 +106,13 @@ func (f *Frame) Reopen() error {
return nil
}
// NewFrame returns a new instance of Frame d/0.
// NewFrame doesnot return with invalid name
func TestFrame_NameRestriction(t *testing.T) {
path, err := ioutil.TempDir("", "pilosa-frame-")
if err != nil {
panic(err)
}
frame, err := pilosa.NewFrame(path, "d", "ABC")
frame, err := pilosa.NewFrame(path, "d", ".meta")
if frame != nil {
t.Fatalf("unexpected frame name %s", err)
}

View file

@ -29,7 +29,7 @@ var (
// Regular expression to valuate db and frame's name
// Todo: remove . when frame doesn't require . for topN
var nameRegexp = regexp.MustCompile(`^([a-z0-9._-]{1,64}$)`)
var nameRegexp = regexp.MustCompile(`^([^.][a-z0-9._-]{1,64}$)`)
// Profile represents vertical column in a database.
// A profile can have a set of attributes attached to it.