30 lines
569 B
Go
Raw Normal View History

package database
import (
"fmt"
"os"
"path/filepath"
"bunker/commons"
)
func (d *database) configureDBPath() error {
rootDir, err := os.UserConfigDir()
if err != nil {
return fmt.Errorf("configure DB path: get config dir: %w", err)
}
rootDir = filepath.Join(rootDir, commons.ClientAppID)
//nolint:mnd
if err := os.MkdirAll(rootDir, 0o700); err != nil {
return fmt.Errorf("configure DB path: create dir: %w", err)
}
d.dbPath = filepath.Join(rootDir, "database.sqlite3")
2025-09-10 20:04:19 +05:00
d.logger.Info("Database path configured.", "path", d.dbPath)
return nil
}