mirror of
https://github.com/etcd-io/bbolt.git
synced 2025-05-31 11:42:30 +00:00
do not read freelist if database opened readonly
This commit is contained in:
parent
12923fe56c
commit
ec37ce8e9b
6
db.go
6
db.go
@ -241,6 +241,10 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if db.readOnly {
|
||||
return db, nil
|
||||
}
|
||||
|
||||
db.freelist = newFreelist()
|
||||
noFreeList := db.meta().freelist == pgidNoFreelist
|
||||
if noFreeList {
|
||||
@ -254,7 +258,7 @@ func Open(path string, mode os.FileMode, options *Options) (*DB, error) {
|
||||
|
||||
// Flush freelist when transitioning from no sync to sync so
|
||||
// NoFreelistSync unaware boltdb can open the db later.
|
||||
if !db.NoFreelistSync && noFreeList && ((mode & 0222) != 0) {
|
||||
if !db.NoFreelistSync && noFreeList {
|
||||
tx, err := db.Begin(true)
|
||||
if tx != nil {
|
||||
err = tx.Commit()
|
||||
|
Loading…
x
Reference in New Issue
Block a user