From 4d1e83e9e71cb66b29b51a48bfd64b72c5498ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6sche?= Date: Sun, 25 Jan 2026 15:26:09 +0100 Subject: [PATCH] Fix public file download timeout - Increase timeout for WebDAV downloads from default to 5 minutes - Prevents 504 Gateway Timeout errors when downloading large files - Uses context.WithTimeout for better control over download duration --- go_cloud/internal/http/routes.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/go_cloud/internal/http/routes.go b/go_cloud/internal/http/routes.go index 3a4f132..5abbcbd 100644 --- a/go_cloud/internal/http/routes.go +++ b/go_cloud/internal/http/routes.go @@ -3174,8 +3174,12 @@ func publicFileViewHandler(w http.ResponseWriter, r *http.Request, db *database. return } + // Create context with longer timeout for file downloads + downloadCtx, cancel := context.WithTimeout(r.Context(), 5*time.Minute) + defer cancel() + // Stream file - resp, err := client.Download(r.Context(), file.Path, r.Header.Get("Range")) + resp, err := client.Download(downloadCtx, file.Path, r.Header.Get("Range")) if err != nil { errors.LogError(r, err, "Failed to download file") errors.WriteError(w, errors.CodeInternal, "Server error", http.StatusInternalServerError)