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

Fix thumbnailing remote files #2789

Merged
merged 9 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions synapse/rest/media/v1/media_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def _get_remote_media_impl(self, server_name, media_id):
# If we have an entry in the DB, try and look for it
if media_info:
if media_info["quarantined_by"]:
logger.info("Media is quarentined")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quarentined

raise NotFoundError()

responder = yield self.media_storage.fetch_media(file_info)
Expand Down
8 changes: 7 additions & 1 deletion synapse/rest/media/v1/thumbnail_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def _respond_local_thumbnail(self, request, media_id, width, height,
media_info = yield self.store.get_local_media(media_id)

if not media_info or media_info["quarantined_by"]:
logger.info("Media is quarantined")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't know for sure it is quarantined here

respond_404(request)
return

Expand All @@ -111,6 +112,7 @@ def _respond_local_thumbnail(self, request, media_id, width, height,
responder = yield self.media_storage.fetch_media(file_info)
yield respond_with_responder(request, responder, t_type, t_length)
else:
logger.info("Couldn't find any generated thumbnails")
respond_404(request)

@defer.inlineCallbacks
Expand All @@ -120,6 +122,7 @@ def _select_or_generate_local_thumbnail(self, request, media_id, desired_width,
media_info = yield self.store.get_local_media(media_id)

if not media_info or media_info["quarantined_by"]:
logger.info("Media is quarantined")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

respond_404(request)
return

Expand Down Expand Up @@ -159,6 +162,7 @@ def _select_or_generate_local_thumbnail(self, request, media_id, desired_width,
if file_path:
yield respond_with_file(request, desired_type, file_path)
else:
logger.warn("Failed to generate local thumbnail")
respond_404(request)

@defer.inlineCallbacks
Expand Down Expand Up @@ -197,7 +201,7 @@ def _select_or_generate_remote_thumbnail(self, request, server_name, media_id,
yield respond_with_responder(request, responder, t_type, t_length)
return

logger.debug("We don't have a local thumbnail of that size. Generating")
logger.debug("We don't have a remote thumbnail of that size. Generating")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrm. we're looking for local thumbnails of remote media, no?


# Okay, so we generate one.
file_path = yield self.media_repo.generate_remote_exact_thumbnail(
Expand All @@ -208,6 +212,7 @@ def _select_or_generate_remote_thumbnail(self, request, server_name, media_id,
if file_path:
yield respond_with_file(request, desired_type, file_path)
else:
logger.warn("Failed to generate remote thumbnail")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/remote/local/ ?

respond_404(request)

@defer.inlineCallbacks
Expand Down Expand Up @@ -241,6 +246,7 @@ def _respond_remote_thumbnail(self, request, server_name, media_id, width,
responder = yield self.media_storage.fetch_media(file_info)
yield respond_with_responder(request, responder, t_type, t_length)
else:
logger.info("Failed to find any generated thumbnails")
respond_404(request)

def _select_thumbnail(self, desired_width, desired_height, desired_method,
Expand Down