From c3fe603df30b9e1c8ec292ae3f556d158eb8b88c Mon Sep 17 00:00:00 2001 From: roseduan Date: Sun, 6 Oct 2024 10:28:39 +0800 Subject: [PATCH] fix DefaultOptions temp dir --- options.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/options.go b/options.go index 2987ae95..e24d3e30 100644 --- a/options.go +++ b/options.go @@ -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 { @@ -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()))) }