@@ -6,6 +6,10 @@ import (
|
||||
)
|
||||
|
||||
func ConfigPath() (string, error) {
|
||||
configHome := os.Getenv("XDG_CONFIG_HOME")
|
||||
if configHome != "" {
|
||||
return filepath.Join(configHome, "iris", "config.toml"), nil
|
||||
}
|
||||
dir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -25,7 +29,19 @@ func StatePath() (string, error) {
|
||||
return filepath.Join(dataHome, "iris", "state.toml"), nil
|
||||
}
|
||||
|
||||
func HistoryDBPath() (string, error) {
|
||||
statePath, err := StatePath()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return filepath.Join(filepath.Dir(statePath), "history.db"), nil
|
||||
}
|
||||
|
||||
func CachePath() (string, error) {
|
||||
cacheHome := os.Getenv("XDG_CACHE_HOME")
|
||||
if cacheHome != "" {
|
||||
return filepath.Join(cacheHome, "iris"), nil
|
||||
}
|
||||
dir, err := os.UserCacheDir()
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/versenilvis/iris/internal/config"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
@@ -37,11 +38,11 @@ type FrecencyStore struct {
|
||||
|
||||
func NewFrecencyStore(dbPath string) (*FrecencyStore, error) {
|
||||
if dbPath == "" {
|
||||
home, err := os.UserHomeDir()
|
||||
var err error
|
||||
dbPath, err = config.HistoryDBPath()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
dbPath = filepath.Join(home, ".local", "share", "iris", "history.db")
|
||||
}
|
||||
|
||||
dir := filepath.Dir(dbPath)
|
||||
|
||||
Reference in New Issue
Block a user