merge github.com/SysLabIT/scribble

This commit is contained in:
Atlas Cove 2021-09-01 22:30:27 +01:00
parent 40c88ff105
commit a5b2727275
1 changed files with 5 additions and 3 deletions

View File

@ -162,7 +162,6 @@ func (d *Driver) Read(collection, resource string, v interface{}) error {
func read(record string, v interface{}) error {
b, err := ioutil.ReadFile(record + ".json")
if err != nil {
return err
}
@ -180,11 +179,14 @@ func (d *Driver) ReadAll(collection string) ([][]byte, error) {
return nil, ErrMissingCollection
}
//
dir := filepath.Join(d.dir, collection)
os.MkdirAll(dir, 0777)
// check to see if collection (directory) exists
if _, err := stat(dir); err != nil {
// read all the files in the transaction.Collection; an error here just means
// the collection is either empty or doesn't exist
files, err := ioutil.ReadDir(dir)
if err != nil {
return nil, err
}