mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-25 22:09:08 +01:00
cleanup sqlite store creation
Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -31,13 +32,13 @@ type SqliteStoreConn struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func NewSqliteStore(ctx context.Context, storeFile, dataDir string) (*SqliteStore, error) {
|
func NewSqliteStore(ctx context.Context, storeFile, dataDir string) (*SqliteStore, error) {
|
||||||
// storeFile := storeSqliteFileName
|
dbfile := storeFile
|
||||||
// if envFile, ok := os.LookupEnv("NB_STORE_ENGINE_SQLITE_FILE"); ok && envFile != "" {
|
if envFile, ok := os.LookupEnv("NB_STORE_ENGINE_SQLITE_FILE"); ok && envFile != "" {
|
||||||
// storeFile = envFile
|
dbfile = envFile
|
||||||
// }
|
}
|
||||||
|
|
||||||
// Separate file path from any SQLite URI query parameters (e.g., "store.db?mode=rwc")
|
// Separate file path from any SQLite URI query parameters (e.g., "store.db?mode=rwc")
|
||||||
filePath, query, hasQuery := strings.Cut(storeFile, "?")
|
filePath, query, hasQuery := strings.Cut(dbfile, "?")
|
||||||
|
|
||||||
connStr := filePath
|
connStr := filePath
|
||||||
if filePath != ":memory:" && !filepath.IsAbs(filePath) {
|
if filePath != ":memory:" && !filepath.IsAbs(filePath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user