Skip to content

Commit

Permalink
fix DefaultOptions temp dir
Browse files Browse the repository at this point in the history
  • Loading branch information
roseduan committed Oct 6, 2024
1 parent b834d30 commit c3fe603
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions options.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package rosedb

import "os"
import (
"math/rand"
"os"
"path/filepath"
"strconv"
"time"
)

// Options specifies the options for opening a database.
type Options struct {
Expand Down Expand Up @@ -68,7 +74,8 @@ var DefaultBatchOptions = BatchOptions{
ReadOnly: false,
}

var nameRand = rand.NewSource(time.Now().UnixNano())

func tempDBDir() string {
dir, _ := os.MkdirTemp("", "rosedb-temp")
return dir
return filepath.Join(os.TempDir(), "rosedb-temp"+strconv.Itoa(int(nameRand.Int63())))
}

0 comments on commit c3fe603

Please sign in to comment.