mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-25 18:11:28 +00:00
Fix cache file
This commit is contained in:
parent
cadc34f3ad
commit
9532d0cba4
|
@ -45,11 +45,24 @@ func Open(path string, cacheID string) (*CacheFile, error) {
|
||||||
}
|
}
|
||||||
err = db.Batch(func(tx *bbolt.Tx) error {
|
err = db.Batch(func(tx *bbolt.Tx) error {
|
||||||
return tx.ForEach(func(name []byte, b *bbolt.Bucket) error {
|
return tx.ForEach(func(name []byte, b *bbolt.Bucket) error {
|
||||||
bucketName := string(name)
|
if name[0] == 0 {
|
||||||
if !(bucketName == string(bucketSelected) || strings.HasPrefix(bucketName, fakeipBucketPrefix)) {
|
return b.ForEachBucket(func(k []byte) error {
|
||||||
delErr := tx.DeleteBucket(name)
|
bucketName := string(k)
|
||||||
if delErr != nil {
|
if !(bucketName == string(bucketSelected)) {
|
||||||
return delErr
|
delErr := b.DeleteBucket(name)
|
||||||
|
if delErr != nil {
|
||||||
|
return delErr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
bucketName := string(name)
|
||||||
|
if !(bucketName == string(bucketSelected) || strings.HasPrefix(bucketName, fakeipBucketPrefix)) {
|
||||||
|
delErr := tx.DeleteBucket(name)
|
||||||
|
if delErr != nil {
|
||||||
|
return delErr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue