Skip to content

Commit 937db7b

Browse files
committed
Don't fail compactdb on corruption but log warning
1 parent d323c0f commit 937db7b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

cmd/chantools/compactdb.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ func (c *compactDBCommand) walkBucket(b *bbolt.Bucket, keypath [][]byte,
165165
return b.ForEach(func(k, v []byte) error {
166166
if v == nil {
167167
bkt := b.Bucket(k)
168+
if bkt == nil {
169+
log.Warnf("Could not read bucket '%s' (full " +
170+
"path '%s') database is likely " +
171+
"corrupted. Continuing anyway but " +
172+
"skipping corrupt bucket.", k, keypath)
173+
return nil
174+
}
168175
return c.walkBucket(
169176
bkt, keypath, k, nil, bkt.Sequence(), fn,
170177
)

0 commit comments

Comments
 (0)