diff options
author | Erik Johnston <erik@matrix.org> | 2018-01-08 17:45:11 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2018-01-09 16:15:07 +0000 |
commit | dd3092c3a357be2453e25293b5590d627f3cfc48 (patch) | |
tree | 68f2a111a78f4ac1be2c925c501959add92ef075 /synapse/rest/media/v1/download_resource.py | |
parent | Add MediaStorage class (diff) | |
download | synapse-dd3092c3a357be2453e25293b5590d627f3cfc48.tar.xz |
Use MediaStorage for local files
Diffstat (limited to 'synapse/rest/media/v1/download_resource.py')
-rw-r--r-- | synapse/rest/media/v1/download_resource.py | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/synapse/rest/media/v1/download_resource.py b/synapse/rest/media/v1/download_resource.py index 6879249c8a..2a5afa9ff4 100644 --- a/synapse/rest/media/v1/download_resource.py +++ b/synapse/rest/media/v1/download_resource.py @@ -57,35 +57,13 @@ class DownloadResource(Resource): ) server_name, media_id, name = parse_media_id(request) if server_name == self.server_name: - yield self._respond_local_file(request, media_id, name) + yield self.media_repo.get_local_media(request, media_id, name) else: yield self._respond_remote_file( request, server_name, media_id, name ) @defer.inlineCallbacks - def _respond_local_file(self, request, media_id, name): - media_info = yield self.store.get_local_media(media_id) - if not media_info or media_info["quarantined_by"]: - respond_404(request) - return - - media_type = media_info["media_type"] - media_length = media_info["media_length"] - upload_name = name if name else media_info["upload_name"] - if media_info["url_cache"]: - # TODO: Check the file still exists, if it doesn't we can redownload - # it from the url `media_info["url_cache"]` - file_path = self.filepaths.url_cache_filepath(media_id) - else: - file_path = self.filepaths.local_media_filepath(media_id) - - yield respond_with_file( - request, media_type, file_path, media_length, - upload_name=upload_name, - ) - - @defer.inlineCallbacks def _respond_remote_file(self, request, server_name, media_id, name): # don't forward requests for remote media if allow_remote is false allow_remote = synapse.http.servlet.parse_boolean( |