Skip to content

Commit 0a9f545

Browse files
committed
firewalldb: add KVStore CRUD logic
1 parent 704acdf commit 0a9f545

File tree

3 files changed

+805
-0
lines changed

3 files changed

+805
-0
lines changed

firewalldb/db.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package firewalldb
22

33
import (
44
"encoding/binary"
5+
"errors"
56
"fmt"
67
"os"
78
"path/filepath"
@@ -106,6 +107,18 @@ func initDB(filepath string, firstInit bool) (*bbolt.DB, error) {
106107
}
107108
}
108109

110+
rulesBucket, err := tx.CreateBucketIfNotExists(rulesBucketKey)
111+
if err != nil {
112+
return err
113+
}
114+
115+
// Delete everything under the "temp" key if such a bucket
116+
// exists.
117+
err = rulesBucket.DeleteBucket(tempBucketKey)
118+
if err != nil && !errors.Is(err, bbolt.ErrBucketNotFound) {
119+
return err
120+
}
121+
109122
actionsBucket, err := tx.CreateBucketIfNotExists(
110123
actionsBucketKey,
111124
)

0 commit comments

Comments
 (0)