leveldb: use 'comma ok' on iterator.ErrorCallbackSetter type assertion (fixes #101)
diff --git a/leveldb/db.go b/leveldb/db.go
index d50a008..323353b 100644
--- a/leveldb/db.go
+++ b/leveldb/db.go
@@ -347,12 +347,14 @@
return err
}
iter := tr.NewIterator(nil, nil)
- iter.(iterator.ErrorCallbackSetter).SetErrorCallback(func(err error) {
- if errors.IsCorrupted(err) {
- s.logf("table@recovery block corruption @%d %q", file.Num(), err)
- tcorruptedBlock++
- }
- })
+ if itererr, ok := iter.(iterator.ErrorCallbackSetter); ok {
+ itererr.SetErrorCallback(func(err error) {
+ if errors.IsCorrupted(err) {
+ s.logf("table@recovery block corruption @%d %q", file.Num(), err)
+ tcorruptedBlock++
+ }
+ })
+ }
// Scan the table.
for iter.Next() {