Added a new sync that uses hash

Added a new sync that uses hash and sqlc for the queries. Added db
migration. Started adding a config file.
This commit is contained in:
2024-12-19 12:11:20 +01:00
parent 8fa93d580d
commit 5ab19e16e5
26 changed files with 1527 additions and 45 deletions

View File

@@ -7,6 +7,7 @@ import (
"music-server/pkg/api"
"music-server/pkg/db"
"music-server/pkg/helpers"
"music-server/pkg/server"
"os"
"strconv"
@@ -15,6 +16,12 @@ import (
)
func SetupDb() {
/*err := server.ReadConf("conf.yaml")
if err != nil {
log.Fatal(err)
}*/
// Get the value of an Environment Variable
host := os.Getenv("DB_HOST")
dbPort, dbPortErr := strconv.Atoi(os.Getenv("DB_PORT"))
@@ -35,16 +42,35 @@ func SetupDb() {
dbPort = 5432
}
if username == "" {
username = "sebastian"
username = "postgres"
}
if password == "" {
password = "950100"
password = "postgres"
}
if dbName == "" {
dbName = "music_dev_local"
dbName = "music_test_local"
}
db.Migrate_db(host, dbPort, username, password, dbName)
db.InitDB(host, dbPort, username, password, dbName)
var dir string
if host != "localhost" {
dir = "/sorted/"
} else {
dir = "/Users/sebastian/ResilioSync/Sorterat_test/"
}
server.Conf = &server.Config{
Host: host,
Port: dbPort,
User: username,
Password: password,
Dbname: dbName,
Path: dir,
}
}
func CloseDb() {
@@ -60,6 +86,7 @@ func SetupRestServer(swagger embed.FS, search embed.FS) {
syncGroup := router.Group("/sync")
{
syncGroup.GET("", sync.SyncGames)
syncGroup.GET("/new", sync.SyncGamesNew)
syncGroup.GET("/quick", sync.SyncGamesQuick)
syncGroup.GET("/reset", sync.ResetGames)
}