Merge branch 'develop' into feature/new-installer

This commit is contained in:
Vladimir Stoilov 2025-01-14 15:30:57 +02:00
commit 5039e9efca
No known key found for this signature in database
GPG key ID: 2F190B67A43A81AF
40 changed files with 929 additions and 163 deletions

View file

@ -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
}