Fix timing on database root path initialization

This commit is contained in:
Daniel
2025-02-26 13:23:38 +01:00
parent 4721e58727
commit 130c4a427c
4 changed files with 10 additions and 14 deletions

View File

@@ -4,8 +4,8 @@ import (
"path/filepath"
"github.com/safing/portmaster/base/database"
"github.com/safing/portmaster/base/database/dbmodule"
_ "github.com/safing/portmaster/base/database/storage/bbolt"
"github.com/safing/portmaster/base/dataroot"
"github.com/safing/portmaster/base/utils"
)
@@ -17,7 +17,7 @@ var (
func registerDatabases() error {
// If there is an existing bbolt core database, use it instead.
coreStorageType := DefaultDatabaseStorageType
if utils.PathExists(filepath.Join(dbmodule.GetDatabaseLocation(), "core", "bbolt")) {
if utils.PathExists(filepath.Join(dataroot.Root().Path, database.DatabasesSubDir, "core", "bbolt")) {
coreStorageType = "bbolt"
}
@@ -33,7 +33,7 @@ func registerDatabases() error {
// If there is an existing cache bbolt database, use it instead.
cacheStorageType := DefaultDatabaseStorageType
if utils.PathExists(filepath.Join(dbmodule.GetDatabaseLocation(), "cache", "bbolt")) {
if utils.PathExists(filepath.Join(dataroot.Root().Path, database.DatabasesSubDir, "cache", "bbolt")) {
cacheStorageType = "bbolt"
}

View File

@@ -6,6 +6,7 @@ import (
"fmt"
"github.com/safing/portmaster/base/api"
"github.com/safing/portmaster/base/database/dbmodule"
"github.com/safing/portmaster/base/dataroot"
"github.com/safing/portmaster/base/info"
"github.com/safing/portmaster/base/utils"
@@ -59,6 +60,9 @@ func prep(instance instance) error {
if err != nil {
return err
}
// Set root dir for the databases.
dbmodule.SetDatabaseLocation(dataroot.Root())
}
// set api listen address