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
This commit is contained in:
Leon Bösche
2026-01-25 15:26:09 +01:00
parent a88121d465
commit 4d1e83e9e7

View File

@@ -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)