add Store Close method (#1500)

* add Store Close method

* Update sync store build failure
This commit is contained in:
Asim Aslam
2020-04-08 09:51:10 +01:00
committed by GitHub
parent 4cac7dcc48
commit 4b0e27413e
11 changed files with 56 additions and 10 deletions

View File

@@ -72,13 +72,13 @@ func (m *fileStore) init(opts ...store.Option) error {
}
// create a directory /tmp/micro
dir := filepath.Join(DefaultDir, "micro")
dir := filepath.Join(DefaultDir, m.options.Database)
// create the database handle
fname := m.options.Database + ".db"
fname := m.options.Table + ".db"
// Ignoring this as the folder might exist.
// Reads/Writes updates will return with sensible error messages
// about the dir not existing in case this cannot create the path anyway
_ = os.Mkdir(dir, 0700)
os.MkdirAll(dir, 0700)
m.dir = dir
m.fileName = fname
@@ -223,6 +223,13 @@ func (m *fileStore) set(r *store.Record) error {
})
}
func (m *fileStore) Close() error {
if m.db != nil {
return m.db.Close()
}
return nil
}
func (m *fileStore) Init(opts ...store.Option) error {
return m.init(opts...)
}