summaryrefslogtreecommitdiffstats
path: root/vendor/gitea.com/lunny/levelqueue/set.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gitea.com/lunny/levelqueue/set.go')
-rw-r--r--vendor/gitea.com/lunny/levelqueue/set.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/vendor/gitea.com/lunny/levelqueue/set.go b/vendor/gitea.com/lunny/levelqueue/set.go
index 88f4e9b1d1..f5995cb8f1 100644
--- a/vendor/gitea.com/lunny/levelqueue/set.go
+++ b/vendor/gitea.com/lunny/levelqueue/set.go
@@ -8,6 +8,7 @@ import (
"sync"
"github.com/syndtr/goleveldb/leveldb"
+ "github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/util"
)
@@ -28,7 +29,13 @@ type Set struct {
func OpenSet(dataDir string) (*Set, error) {
db, err := leveldb.OpenFile(dataDir, nil)
if err != nil {
- return nil, err
+ if !errors.IsCorrupted(err) {
+ return nil, err
+ }
+ db, err = leveldb.RecoverFile(dataDir, nil)
+ if err != nil {
+ return nil, err
+ }
}
return NewSet(db, []byte(setPrefixStr), true)
}