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:
@@ -3174,8 +3174,12 @@ func publicFileViewHandler(w http.ResponseWriter, r *http.Request, db *database.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create context with longer timeout for file downloads
|
||||||
|
downloadCtx, cancel := context.WithTimeout(r.Context(), 5*time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
// Stream file
|
// 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 {
|
if err != nil {
|
||||||
errors.LogError(r, err, "Failed to download file")
|
errors.LogError(r, err, "Failed to download file")
|
||||||
errors.WriteError(w, errors.CodeInternal, "Server error", http.StatusInternalServerError)
|
errors.WriteError(w, errors.CodeInternal, "Server error", http.StatusInternalServerError)
|
||||||
|
|||||||
Reference in New Issue
Block a user