fix: 2.6-stable - fixes

This commit is contained in:
Alexander Renz 2025-01-26 18:58:08 +01:00
parent af5aaa528c
commit b05c444a0a
2 changed files with 13 additions and 14 deletions

View File

@ -1,4 +1,4 @@
# HMAC File Server 2.5-Stable
# HMAC File Server 2.6-Stable
## Overview
The **HMAC File Server** ensures secure file uploads and downloads using HMAC authentication. It incorporates rate limiting, CORS support, retries, file versioning, and Unix socket support for enhanced flexibility. Redis integration provides efficient caching and session management. Prometheus metrics and a graceful shutdown mechanism ensure reliable and efficient file handling.

View File

@ -514,7 +514,6 @@ func main() {
log.Fatalf("Insufficient free space: %v", err)
}
initializeWorkerSettings(&conf.Server, &conf.Workers, &conf.ClamAV)
log.Info("Prometheus metrics initialized.")
networkEvents = make(chan NetworkEvent, 100)
@ -1790,18 +1789,9 @@ func handleUpload(w http.ResponseWriter, r *http.Request, absFilename, fileStore
}
// Determine the final filename based on the FileNaming configuration
finalFilename := absFilename
switch conf.Server.FileNaming {
case "HMAC":
finalFilename = filepath.Join(filepath.Dir(absFilename), hex.EncodeToString(calculatedMAC)+filepath.Ext(absFilename))
case "None", "none":
// Do nothing: keep finalFilename as-is
default:
log.Warnf("Unrecognized filenaming config %q, skipping rename.", conf.Server.FileNaming)
}
finalFilename := getFinalFilename(absFilename)
// Create temp file and write the uploaded data
tempFilename := finalFilename + ".tmp"
tempFilename := getTempFilename(finalFilename)
err = createFile(tempFilename, r)
if err != nil {
log.WithFields(logrus.Fields{
@ -2752,3 +2742,12 @@ func setupRouter() *http.ServeMux {
router.HandleFunc("/", handleRequest)
return router
}
func getFinalFilename(absFilename string) string {
// Use config if needed, or just return absFilename for now
return absFilename
}
func getTempFilename(filename string) string {
return filename + ".tmp"
}