diff options
Diffstat (limited to 'cmd/bolt/check.go')
-rw-r--r-- | cmd/bolt/check.go | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/cmd/bolt/check.go b/cmd/bolt/check.go index 1436aba..1466fd7 100644 --- a/cmd/bolt/check.go +++ b/cmd/bolt/check.go @@ -21,19 +21,27 @@ func Check(path string) { defer db.Close() // Perform consistency check. - err = db.View(func(tx *bolt.Tx) error { - return tx.Check() - }) - - // Print out any errors that occur. - if err != nil { - if errors, ok := err.(bolt.ErrorList); ok { - for _, err := range errors { + _ = db.View(func(tx *bolt.Tx) error { + var count int + ch := tx.Check() + loop: + for { + select { + case err, ok := <-ch: + if !ok { + break loop + } println(err) + count++ } } - fatalln(err) - return - } - println("OK") + + // Print summary of errors. + if count > 0 { + fatalf("%d errors found") + } else { + println("OK") + } + return nil + }) } |