This commit is contained in:
2025-04-14 23:35:10 +03:00
parent e3aaa88822
commit 6d5016270f
21 changed files with 449 additions and 349 deletions

View File

@ -28,6 +28,7 @@ import (
"github.com/caarlos0/env"
"github.com/pelletier/go-toml/v2"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/constants"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
)
@ -83,14 +84,9 @@ func mergeStructs(dst, src interface{}) {
}
}
const (
systemConfigPath = "/etc/alr/alr.toml"
systemCachePath = "/var/cache/alr"
)
func (c *ALRConfig) Load() error {
systemConfig, err := readConfig(
systemConfigPath,
constants.SystemConfigPath,
)
if err != nil {
slog.Debug("Cannot read system config", "err", err)
@ -108,8 +104,8 @@ func (c *ALRConfig) Load() error {
c.cfg = config
c.paths = &Paths{}
c.paths.UserConfigPath = systemConfigPath
c.paths.CacheDir = systemCachePath
c.paths.UserConfigPath = constants.SystemConfigPath
c.paths.CacheDir = constants.SystemCachePath
c.paths.RepoDir = filepath.Join(c.paths.CacheDir, "repo")
c.paths.PkgsDir = filepath.Join(c.paths.CacheDir, "pkgs")
c.paths.DBPath = filepath.Join(c.paths.CacheDir, "db")