local var name fixes

This commit is contained in:
2026-01-28 19:05:40 +01:00
parent 123af105f4
commit c0ab94510e
11 changed files with 107 additions and 107 deletions
+10 -10
View File
@@ -19,33 +19,33 @@ func NewDownloadController(service domain.DownloadServiceInterface) *DownloadCon
return &DownloadController{service: service}
}
func (c *DownloadController) serve(w http.ResponseWriter, r *http.Request, release *domain.Release, isSource bool) {
var filePath string
if isSource {
filePath = release.SourcePath
func (c *DownloadController) serve(w http.ResponseWriter, r *http.Request, release *domain.Release, is_source bool) {
var file_path string
if is_source {
file_path = release.SourcePath
} else {
filePath = release.CartridgePath
file_path = release.CartridgePath
}
absFilePath, err := filepath.Abs(filePath)
abs_file_path, err := filepath.Abs(file_path)
if err != nil {
http.Error(w, "Invalid file path", http.StatusInternalServerError)
return
}
absContentsDir, err := filepath.Abs(os.Getenv("FILE_CONTAINER_PATH"))
abs_contents_dir, err := filepath.Abs(os.Getenv("FILE_CONTAINER_PATH"))
if err != nil {
http.Error(w, "Invalid contents directory path", http.StatusInternalServerError)
return
}
if !strings.HasPrefix(absFilePath, absContentsDir) {
if !strings.HasPrefix(abs_file_path, abs_contents_dir) {
http.Error(w, "Access denied", http.StatusForbidden)
return
}
w.Header().Set("Content-Disposition", "attachment; filename="+filepath.Base(filePath))
http.ServeFile(w, r, filePath)
w.Header().Set("Content-Disposition", "attachment; filename="+filepath.Base(file_path))
http.ServeFile(w, r, file_path)
}
func (c *DownloadController) handleError(w http.ResponseWriter, err error) {