mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-20 02:00:11 -08:00
upgrade buntdb
This commit is contained in:
parent
af124cd964
commit
b6f6959acc
4 changed files with 18 additions and 3 deletions
15
vendor/github.com/tidwall/buntdb/buntdb.go
generated
vendored
15
vendor/github.com/tidwall/buntdb/buntdb.go
generated
vendored
|
|
@ -10,6 +10,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
|
@ -753,7 +754,7 @@ func (db *DB) Shrink() error {
|
|||
return err
|
||||
}
|
||||
// Any failures below here are really bad. So just panic.
|
||||
if err := os.Rename(tmpname, fname); err != nil {
|
||||
if err := renameFile(tmpname, fname); err != nil {
|
||||
panicErr(err)
|
||||
}
|
||||
db.file, err = os.OpenFile(fname, os.O_CREATE|os.O_RDWR, 0666)
|
||||
|
|
@ -773,6 +774,18 @@ func panicErr(err error) error {
|
|||
panic(fmt.Errorf("buntdb: %w", err))
|
||||
}
|
||||
|
||||
func renameFile(src, dest string) error {
|
||||
var err error
|
||||
if err = os.Rename(src, dest); err != nil {
|
||||
if runtime.GOOS == "windows" {
|
||||
if err = os.Remove(dest); err == nil {
|
||||
err = os.Rename(src, dest)
|
||||
}
|
||||
}
|
||||
}
|
||||
return 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().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue