diff --git a/db.go b/db.go index c178bd5b2..2fcd13363 100644 --- a/db.go +++ b/db.go @@ -223,12 +223,12 @@ func Open(opt Options) (db *DB, err error) { if err != nil { return nil, err } + defer func() { + if valueDirLockGuard != nil { + _ = valueDirLockGuard.release() + } + }() } - defer func() { - if valueDirLockGuard != nil { - _ = valueDirLockGuard.release() - } - }() if !(opt.ValueLogFileSize <= 2<<30 && opt.ValueLogFileSize >= 1<<20) { return nil, ErrValueLogSize } diff --git a/errors.go b/errors.go index 130635752..a0c180687 100644 --- a/errors.go +++ b/errors.go @@ -27,7 +27,7 @@ var ( // ErrValueThreshold is returned when ValueThreshold is set to a value close to or greater than // uint16. - ErrValueThreshold = errors.New("Invalid ValueThreshold, must be lower than uint16.") + ErrValueThreshold = errors.New("Invalid ValueThreshold, must be lower than uint16") // ErrKeyNotFound is returned when key isn't found on a txn.Get. ErrKeyNotFound = errors.New("Key not found") diff --git a/images/sketch.jpg b/images/sketch.jpg deleted file mode 100644 index e1ea10ebd..000000000 Binary files a/images/sketch.jpg and /dev/null differ diff --git a/options.go b/options.go index f9b195fa5..de2a32aa9 100644 --- a/options.go +++ b/options.go @@ -31,10 +31,11 @@ import ( type Options struct { // 1. Mandatory flags // ------------------- - // Directory to store the data in. Should exist and be writable. + // Directory to store the data in. If it doesn't exist, Badger will + // try to create it for you. Dir string - // Directory to store the value log in. Can be the same as Dir. Should - // exist and be writable. + // Directory to store the value log in. Can be the same as Dir. If it + // doesn't exist, Badger will try to create it for you. ValueDir string // 2. Frequently modified flags diff --git a/txn.go b/txn.go index 7c2849e4c..3fff2df74 100644 --- a/txn.go +++ b/txn.go @@ -616,13 +616,13 @@ func runTxnCallback(cb *txnCb) { switch { case cb == nil: panic("txn callback is nil") + case cb.user == nil: + panic("Must have caught a nil callback for txn.CommitWith") case cb.err != nil: cb.user(cb.err) case cb.commit != nil: err := cb.commit() cb.user(err) - case cb.user == nil: - panic("Must have caught a nil callback for txn.CommitWith") default: cb.user(nil) } diff --git a/value_test.go b/value_test.go index 4085762ab..37f04b53a 100644 --- a/value_test.go +++ b/value_test.go @@ -102,7 +102,7 @@ func TestValueGCManaged(t *testing.T) { var ts uint64 newTs := func() uint64 { - ts += 1 + ts++ return ts }