From a32aceaad83eef37e564fde88bfba99a920f9050 Mon Sep 17 00:00:00 2001 From: andig Date: Fri, 15 Aug 2025 13:59:03 +0200 Subject: [PATCH] Config UI: set content-length for backup download (#23002) --- server/http_site_handler.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/http_site_handler.go b/server/http_site_handler.go index 2b03f8ad5..21e591725 100644 --- a/server/http_site_handler.go +++ b/server/http_site_handler.go @@ -379,6 +379,13 @@ func getBackup(authObject auth.Auth) http.HandlerFunc { filename := "evcc-backup-" + time.Now().Format("2006-01-02--15-04") + ".db" + fi, err := f.Stat() + if err != nil { + http.Error(w, "Could not stat DB file: "+err.Error(), http.StatusInternalServerError) + return + } + + w.Header().Set("Content-Length", strconv.FormatInt(fi.Size(), 10)) w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Disposition", `attachment; filename="`+filename+`"`)