Fix timing on database root path initialization
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/safing/portmaster/base/database"
|
||||
"github.com/safing/portmaster/base/dataroot"
|
||||
"github.com/safing/portmaster/base/utils"
|
||||
"github.com/safing/portmaster/service/mgr"
|
||||
)
|
||||
@@ -36,13 +35,7 @@ func SetDatabaseLocation(dirStructureRoot *utils.DirStructure) {
|
||||
}
|
||||
}
|
||||
|
||||
// GetDatabaseLocation returns the initialized database location.
|
||||
func GetDatabaseLocation() string {
|
||||
return databaseStructureRoot.Path
|
||||
}
|
||||
|
||||
func prep() error {
|
||||
SetDatabaseLocation(dataroot.Root())
|
||||
if databaseStructureRoot == nil {
|
||||
return errors.New("database location not specified")
|
||||
}
|
||||
|
||||
@@ -9,9 +9,8 @@ import (
|
||||
"github.com/safing/portmaster/base/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
databasesSubDir = "databases"
|
||||
)
|
||||
// DatabasesSubDir defines the sub directory where the databases are stored.
|
||||
const DatabasesSubDir = "databases"
|
||||
|
||||
var (
|
||||
initialized = abool.NewBool(false)
|
||||
@@ -34,7 +33,7 @@ func Initialize(dirStructureRoot *utils.DirStructure) error {
|
||||
rootStructure = dirStructureRoot
|
||||
|
||||
// ensure root and databases dirs
|
||||
databasesStructure = rootStructure.ChildDir(databasesSubDir, utils.AdminOnlyPermission)
|
||||
databasesStructure = rootStructure.ChildDir(DatabasesSubDir, utils.AdminOnlyPermission)
|
||||
err := databasesStructure.Ensure()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create/open database directory (%s): %w", rootStructure.Path, err)
|
||||
|
||||
Reference in New Issue
Block a user