refactor: open track store explicitly and remove global state

This commit is contained in:
Mathis Maquenne
2026-08-05 11:34:27 +02:00
parent 714d567603
commit 0ab25addd5
7 changed files with 61 additions and 47 deletions
+25
View File
@@ -0,0 +1,25 @@
package config
import (
"os"
"path/filepath"
)
func MigrateLegacy(outputDir string) {
homeDir, err := os.UserHomeDir()
if err != nil {
return
}
oldDB := filepath.Join(homeDir, ".godeez", "tracks.db")
newDB := filepath.Join(outputDir, ".tracks.db")
if _, err := os.Stat(oldDB); err == nil {
if _, err := os.Stat(newDB); os.IsNotExist(err) {
os.Rename(oldDB, newDB)
}
}
oldDir := filepath.Join(homeDir, ".godeez")
os.Remove(filepath.Join(oldDir, "config.toml"))
os.Remove(oldDir)
}