mirror of
https://github.com/safing/portmaster
synced 2025-09-10 06:14:41 +00:00
Merge branch 'develop' into feature/new-installer
This commit is contained in:
commit
5039e9efca
40 changed files with 929 additions and 163 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/safing/portmaster/base/utils"
|
||||
"github.com/tevino/abool"
|
||||
)
|
||||
|
||||
|
@ -23,10 +24,14 @@ func Initialize(databasesRootDir string) error {
|
|||
if initialized.SetToIf(false, true) {
|
||||
rootDir = databasesRootDir
|
||||
|
||||
// Ensure database root dir exists.
|
||||
err := os.MkdirAll(rootDir, 0o0700)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create/open database directory (%s): %w", rootDir, err)
|
||||
return fmt.Errorf("failed to create/check database dir %q: %w", rootDir, err)
|
||||
}
|
||||
// ensure root and databases dirs
|
||||
err = utils.EnsureDirectory(rootDir, utils.AdminOnlyPermission)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not set permissions to database directory (%s): %w", rootDir, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -63,5 +68,9 @@ func getLocation(name, storageType string) (string, error) {
|
|||
if err != nil {
|
||||
return "", fmt.Errorf("failed to create/check database dir %q: %w", location, err)
|
||||
}
|
||||
err = utils.EnsureDirectory(location, utils.AdminOnlyPermission)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not set permissions to directory (%s): %w", location, err)
|
||||
}
|
||||
return location, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue