From b7896919761d1f942a042603510b30921a8c2009 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Wed, 28 May 2014 10:28:15 -0600 Subject: Add streaming check. This commit changes Tx.Check() to return a channel through which check errors are returned. This allows errors to be found before checking the entire data file. --- db_test.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'db_test.go') diff --git a/db_test.go b/db_test.go index 06accd3..e1c4aaa 100644 --- a/db_test.go +++ b/db_test.go @@ -53,12 +53,12 @@ func TestOpen_Check(t *testing.T) { withTempPath(func(path string) { db, err := Open(path, 0666) assert.NoError(t, err) - assert.NoError(t, db.View(func(tx *Tx) error { return tx.Check() })) + assert.NoError(t, db.View(func(tx *Tx) error { return <-tx.Check() })) db.Close() db, err = Open(path, 0666) assert.NoError(t, err) - assert.NoError(t, db.View(func(tx *Tx) error { return tx.Check() })) + assert.NoError(t, db.View(func(tx *Tx) error { return <-tx.Check() })) db.Close() }) } @@ -464,20 +464,13 @@ func withOpenDB(fn func(*DB, string)) { // mustCheck runs a consistency check on the database and panics if any errors are found. func mustCheck(db *DB) { err := db.Update(func(tx *Tx) error { - return tx.Check() + return <-tx.Check() }) if err != nil { // Copy db off first. var path = tempfile() db.View(func(tx *Tx) error { return tx.CopyFile(path, 0600) }) - - if errors, ok := err.(ErrorList); ok { - for _, err := range errors { - warn(err) - } - } - warn(err) - panic("check failure: " + path) + panic("check failure: " + err.Error() + ": " + path) } } -- cgit v1.2.3