upgrade buntdb and dependencies

This commit is contained in:
Shivaram Lingamneni
2023-01-15 08:26:32 -05:00
parent b2087977d0
commit 3f5de80afd
12 changed files with 2078 additions and 419 deletions

View File

@@ -7,6 +7,7 @@ package buntdb
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"sort"
@@ -749,13 +750,13 @@ func (db *DB) Shrink() error {
if err := db.file.Close(); err != nil {
return err
}
// Any failures below here is really bad. So just panic.
// Any failures below here are really bad. So just panic.
if err := os.Rename(tmpname, fname); err != nil {
panic(err)
panicErr(err)
}
db.file, err = os.OpenFile(fname, os.O_CREATE|os.O_RDWR, 0666)
if err != nil {
panic(err)
panicErr(err)
}
pos, err := db.file.Seek(0, 2)
if err != nil {
@@ -766,6 +767,10 @@ func (db *DB) Shrink() error {
}()
}
func panicErr(err error) error {
panic(fmt.Errorf("buntdb: %w", err))
}
// readLoad reads from the reader and loads commands into the database.
// modTime is the modified time of the reader, should be no greater than
// the current time.Now().
@@ -1209,10 +1214,10 @@ func (tx *Tx) Commit() error {
// should be killed to avoid corrupting the file.
pos, err := tx.db.file.Seek(-int64(n), 1)
if err != nil {
panic(err)
panicErr(err)
}
if err := tx.db.file.Truncate(pos); err != nil {
panic(err)
panicErr(err)
}
}
tx.rollbackInner()