From a5b2727275654b82178cc974268f5dacddc8e5b2 Mon Sep 17 00:00:00 2001 From: Atlas Cove Date: Wed, 1 Sep 2021 22:30:27 +0100 Subject: [PATCH] merge github.com/SysLabIT/scribble --- scribble.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scribble.go b/scribble.go index a7e5343..4fecf1d 100644 --- a/scribble.go +++ b/scribble.go @@ -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 }