merge github.com/SysLabIT/scribble
This commit is contained in:
parent
40c88ff105
commit
a5b2727275
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue