mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-10 08:23:11 -06:00
mediaapi/writers/download: Rename attempts to tries
Tries is more usual language in programming.
This commit is contained in:
parent
304a275e1b
commit
563330b82a
|
|
@ -81,7 +81,7 @@ var errRead = fmt.Errorf("failed to read response from remote server")
|
||||||
var errResponse = fmt.Errorf("failed to write file data to response body")
|
var errResponse = fmt.Errorf("failed to write file data to response body")
|
||||||
var errWrite = fmt.Errorf("failed to write file to disk")
|
var errWrite = fmt.Errorf("failed to write file to disk")
|
||||||
|
|
||||||
var nAttempts = 5
|
var nTries = 5
|
||||||
|
|
||||||
// Download implements /download
|
// Download implements /download
|
||||||
// Files from this server (i.e. origin == cfg.ServerName) are served directly
|
// Files from this server (i.e. origin == cfg.ServerName) are served directly
|
||||||
|
|
@ -129,7 +129,7 @@ func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName,
|
||||||
|
|
||||||
mxcURL := "mxc://" + string(r.MediaMetadata.Origin) + "/" + string(r.MediaMetadata.MediaID)
|
mxcURL := "mxc://" + string(r.MediaMetadata.Origin) + "/" + string(r.MediaMetadata.MediaID)
|
||||||
|
|
||||||
for attempts := 0; ; attempts++ {
|
for tries := 0; ; tries++ {
|
||||||
activeRemoteRequests.Lock()
|
activeRemoteRequests.Lock()
|
||||||
err = db.GetMediaMetadata(r.MediaMetadata.MediaID, r.MediaMetadata.Origin, r.MediaMetadata)
|
err = db.GetMediaMetadata(r.MediaMetadata.MediaID, r.MediaMetadata.Origin, r.MediaMetadata)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
@ -139,7 +139,7 @@ func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName,
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if activeRemoteRequestCondition, ok := activeRemoteRequests.Set[mxcURL]; ok {
|
if activeRemoteRequestCondition, ok := activeRemoteRequests.Set[mxcURL]; ok {
|
||||||
if attempts >= nAttempts {
|
if tries >= nTries {
|
||||||
logger.Warnf("Other goroutines are trying to download the remote file and failing.")
|
logger.Warnf("Other goroutines are trying to download the remote file and failing.")
|
||||||
jsonErrorResponse(w, util.JSONResponse{
|
jsonErrorResponse(w, util.JSONResponse{
|
||||||
Code: 500,
|
Code: 500,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue