Browse Source

fix: calculate dbPathName much earlier on!
The bug made things break _before_ the KV Stores managed to take a shot at it

Gwyneth Llewelyn 5 months ago
parent
commit
2132a3c0ac
1 changed files with 4 additions and 3 deletions
  1. 4 3
      gosl.go

+ 4 - 3
gosl.go

@@ -248,6 +248,7 @@ func main() {
 			logging.SetBackend(backendFileLeveled)	// FastCGI only logs to file
 		}
 	*/
+	goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, goslConfig.databaseName)
 
 	log.Debugf("Full config: %+v\n", goslConfig)
 
@@ -276,7 +277,7 @@ func main() {
 		if goslConfig.noMemory {
 			// use disk; note that unlike the others, Badger generates its own filenames,
 			// we can only pass a _directory_... (gwyneth 20211027)
-			goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, goslConfig.databaseName)
+			// goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, goslConfig.databaseName)
 			// try to create directory
 			if err = os.Mkdir(goslConfig.dbNamePath, 0700); err != nil {
 				if !os.IsExist(err) {
@@ -349,7 +350,7 @@ func main() {
 			log.Debugf("badger SET %+v (json: %v)\n", testValue, string(jsonTestValue))
 			kv.Close()
 		case "buntdb":
-			goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, goslConfig.databaseName)
+			// goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, goslConfig.databaseName)
 			db, err := buntdb.Open(goslConfig.dbNamePath)
 			checkErrPanic(err)
 			err = db.Update(func(tx *buntdb.Tx) error {
@@ -360,7 +361,7 @@ func main() {
 			log.Debugf("buntdb SET %+v (json: %v)\n", testValue, string(jsonTestValue))
 			db.Close()
 		case "leveldb":
-			goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, goslConfig.databaseName)
+			// goslConfig.dbNamePath = filepath.Join(goslConfig.myDir, goslConfig.databaseName)
 			db, err := leveldb.OpenFile(goslConfig.dbNamePath, nil)
 			checkErrPanic(err)
 			err = db.Put([]byte(testAvatarName), jsonTestValue, nil)