feat: retrieve modified file paths using hashes

This commit is contained in:
Mathis Maquenne
2025-04-26 14:10:27 +02:00
parent 6d3935c744
commit 917ac5f6c2
6 changed files with 127 additions and 55 deletions
+1
View File
@@ -12,6 +12,7 @@ type DownloadInfo struct {
SongID string `json:"song_id"`
Quality string `json:"quality"`
Path string `json:"path"`
Hash string `json:"hash"`
Downloaded time.Time `json:"downloaded_at"`
}
+3 -14
View File
@@ -5,7 +5,6 @@ import (
"os"
"path"
"github.com/mathismqn/godeez/internal/utils"
bolt "go.etcd.io/bbolt"
)
@@ -14,20 +13,10 @@ var (
trackBucket = []byte("tracks")
)
func Init() {
homeDir, err := os.UserHomeDir()
if err != nil {
fmt.Fprintf(os.Stderr, "Error: could not get home directory: %v\n", err)
os.Exit(1)
}
func Init(cfgDir string) {
var err error
appDir := path.Join(homeDir, ".godeez")
if err := utils.EnsureDir(appDir); err != nil {
fmt.Fprintf(os.Stderr, "Error: could not create app directory: %v\n", err)
os.Exit(1)
}
dbPath := path.Join(appDir, "tracks.db")
dbPath := path.Join(cfgDir, "tracks.db")
db, err = bolt.Open(dbPath, 0600, nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Error: could not open database: %v\n", err)