file songs file path form pasted dir

This commit is contained in:
2025-07-27 14:03:11 +02:00
parent 841a569da7
commit 2079cfaada
2 changed files with 4 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import (
"log"
"net/http"
"os"
"path/filepath"
v1 "backend/gen"
"backend/internal/db"
@@ -248,7 +249,7 @@ func (s *Server) songFile(w http.ResponseWriter, r *http.Request) {
return
}
file, err := os.Open(s.OsuDir + "Songs/" + string(filename))
file, err := os.Open(filepath.Join(s.OsuDir, "Songs", string(filename)))
if err != nil {
fmt.Println(err)
http.Error(w, ErrFileNotFound.Error(), http.StatusNotFound)
@@ -280,7 +281,7 @@ func (s *Server) imageFile(w http.ResponseWriter, r *http.Request) {
return
}
http.ServeFile(w, r, s.OsuDir+"Songs/"+string(filename))
http.ServeFile(w, r, filepath.Join(s.OsuDir, "Songs", string(filename)))
}
func (s *Server) callback(w http.ResponseWriter, r *http.Request) {