Merge pull request #862 from matrix-org/erikj/media_remote_error
502 on /thumbnail when can't contact remote serverpull/863/head
commit
5ee5b655b2
|
@ -26,6 +26,7 @@ from .thumbnailer import Thumbnailer
|
||||||
|
|
||||||
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
|
from synapse.http.matrixfederationclient import MatrixFederationHttpClient
|
||||||
from synapse.util.stringutils import random_string
|
from synapse.util.stringutils import random_string
|
||||||
|
from synapse.api.errors import SynapseError
|
||||||
|
|
||||||
from twisted.internet import defer, threads
|
from twisted.internet import defer, threads
|
||||||
|
|
||||||
|
@ -134,10 +135,15 @@ class MediaRepository(object):
|
||||||
request_path = "/".join((
|
request_path = "/".join((
|
||||||
"/_matrix/media/v1/download", server_name, media_id,
|
"/_matrix/media/v1/download", server_name, media_id,
|
||||||
))
|
))
|
||||||
|
try:
|
||||||
length, headers = yield self.client.get_file(
|
length, headers = yield self.client.get_file(
|
||||||
server_name, request_path, output_stream=f,
|
server_name, request_path, output_stream=f,
|
||||||
max_size=self.max_upload_size,
|
max_size=self.max_upload_size,
|
||||||
)
|
)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warn("Failed to fetch remoted media %r", e)
|
||||||
|
raise SynapseError(502, "Failed to fetch remoted media")
|
||||||
|
|
||||||
media_type = headers["Content-Type"][0]
|
media_type = headers["Content-Type"][0]
|
||||||
time_now_ms = self.clock.time_msec()
|
time_now_ms = self.clock.time_msec()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue