mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-08 15:33:09 -06:00
mediaapi/writers/download: Move log messages to correct code paths
This commit is contained in:
parent
563330b82a
commit
f0c6ec23c9
|
|
@ -122,10 +122,6 @@ func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName,
|
||||||
return
|
return
|
||||||
} else if err == sql.ErrNoRows && r.MediaMetadata.Origin != cfg.ServerName {
|
} else if err == sql.ErrNoRows && r.MediaMetadata.Origin != cfg.ServerName {
|
||||||
// If we do not have a record and the origin is remote, we need to fetch it and respond with that file
|
// If we do not have a record and the origin is remote, we need to fetch it and respond with that file
|
||||||
logger.WithFields(log.Fields{
|
|
||||||
"MediaID": r.MediaMetadata.MediaID,
|
|
||||||
"Origin": r.MediaMetadata.Origin,
|
|
||||||
}).Infof("Fetching remote file")
|
|
||||||
|
|
||||||
mxcURL := "mxc://" + string(r.MediaMetadata.Origin) + "/" + string(r.MediaMetadata.MediaID)
|
mxcURL := "mxc://" + string(r.MediaMetadata.Origin) + "/" + string(r.MediaMetadata.MediaID)
|
||||||
|
|
||||||
|
|
@ -140,7 +136,10 @@ func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName,
|
||||||
}
|
}
|
||||||
if activeRemoteRequestCondition, ok := activeRemoteRequests.Set[mxcURL]; ok {
|
if activeRemoteRequestCondition, ok := activeRemoteRequests.Set[mxcURL]; ok {
|
||||||
if tries >= nTries {
|
if tries >= nTries {
|
||||||
logger.Warnf("Other goroutines are trying to download the remote file and failing.")
|
logger.WithFields(log.Fields{
|
||||||
|
"MediaID": r.MediaMetadata.MediaID,
|
||||||
|
"Origin": r.MediaMetadata.Origin,
|
||||||
|
}).Warnf("Other goroutines are trying to download the remote file and failing.")
|
||||||
jsonErrorResponse(w, util.JSONResponse{
|
jsonErrorResponse(w, util.JSONResponse{
|
||||||
Code: 500,
|
Code: 500,
|
||||||
JSON: jsonerror.Unknown(fmt.Sprintf("File with media ID %q could not be downloaded from %q", r.MediaMetadata.MediaID, r.MediaMetadata.Origin)),
|
JSON: jsonerror.Unknown(fmt.Sprintf("File with media ID %q could not be downloaded from %q", r.MediaMetadata.MediaID, r.MediaMetadata.Origin)),
|
||||||
|
|
@ -154,6 +153,10 @@ func Download(w http.ResponseWriter, req *http.Request, origin types.ServerName,
|
||||||
activeRemoteRequestCondition.Wait()
|
activeRemoteRequestCondition.Wait()
|
||||||
activeRemoteRequests.Unlock()
|
activeRemoteRequests.Unlock()
|
||||||
} else {
|
} else {
|
||||||
|
logger.WithFields(log.Fields{
|
||||||
|
"MediaID": r.MediaMetadata.MediaID,
|
||||||
|
"Origin": r.MediaMetadata.Origin,
|
||||||
|
}).Infof("Fetching remote file")
|
||||||
activeRemoteRequests.Set[mxcURL] = &sync.Cond{L: activeRemoteRequests}
|
activeRemoteRequests.Set[mxcURL] = &sync.Cond{L: activeRemoteRequests}
|
||||||
activeRemoteRequests.Unlock()
|
activeRemoteRequests.Unlock()
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue