Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #862 from matrix-org/erikj/media_remote_error
Browse files Browse the repository at this point in the history
502 on /thumbnail when can't contact remote server
  • Loading branch information
erikjohnston committed Jun 9, 2016
2 parents 0a43219 + eba4ff1 commit 5ee5b65
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions synapse/rest/media/v1/media_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from synapse.http.matrixfederationclient import MatrixFederationHttpClient
from synapse.util.stringutils import random_string
from synapse.api.errors import SynapseError

from twisted.internet import defer, threads

Expand Down Expand Up @@ -134,10 +135,15 @@ def _download_remote_file(self, server_name, media_id):
request_path = "/".join((
"/_matrix/media/v1/download", server_name, media_id,
))
length, headers = yield self.client.get_file(
server_name, request_path, output_stream=f,
max_size=self.max_upload_size,
)
try:
length, headers = yield self.client.get_file(
server_name, request_path, output_stream=f,
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]
time_now_ms = self.clock.time_msec()

Expand Down

0 comments on commit 5ee5b65

Please sign in to comment.