Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
a4c5e4a6
Commit
a4c5e4a6
authored
7 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Fix thumbnailing remote files
parent
1159abbd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
synapse/rest/media/v1/media_repository.py
+28
-0
28 additions, 0 deletions
synapse/rest/media/v1/media_repository.py
synapse/rest/media/v1/thumbnail_resource.py
+2
-2
2 additions, 2 deletions
synapse/rest/media/v1/thumbnail_resource.py
with
30 additions
and
2 deletions
synapse/rest/media/v1/media_repository.py
+
28
−
0
View file @
a4c5e4a6
...
@@ -227,6 +227,34 @@ class MediaRepository(object):
...
@@ -227,6 +227,34 @@ class MediaRepository(object):
else
:
else
:
respond_404
(
request
)
respond_404
(
request
)
@defer.inlineCallbacks
def
get_remote_media_info
(
self
,
server_name
,
media_id
):
"""
Gets the media info associated with the remote file, downloading
if necessary.
Args:
server_name (str): Remote server_name where the media originated.
media_id (str): The media ID of the content (as defined by the
remote server).
Returns:
Deferred[dict]: The media_info of the file
"""
# We linearize here to ensure that we don't try and download remote
# media multiple times concurrently
key
=
(
server_name
,
media_id
)
with
(
yield
self
.
remote_media_linearizer
.
queue
(
key
)):
responder
,
media_info
=
yield
self
.
_get_remote_media_impl
(
server_name
,
media_id
,
)
# Ensure we actually use the responder so that it releases resources
if
responder
:
with
responder
:
pass
defer
.
returnValue
(
media_info
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
_get_remote_media_impl
(
self
,
server_name
,
media_id
):
def
_get_remote_media_impl
(
self
,
server_name
,
media_id
):
"""
Looks for media in local cache, if not there then attempt to
"""
Looks for media in local cache, if not there then attempt to
...
...
This diff is collapsed.
Click to expand it.
synapse/rest/media/v1/thumbnail_resource.py
+
2
−
2
View file @
a4c5e4a6
...
@@ -165,7 +165,7 @@ class ThumbnailResource(Resource):
...
@@ -165,7 +165,7 @@ class ThumbnailResource(Resource):
def
_select_or_generate_remote_thumbnail
(
self
,
request
,
server_name
,
media_id
,
def
_select_or_generate_remote_thumbnail
(
self
,
request
,
server_name
,
media_id
,
desired_width
,
desired_height
,
desired_width
,
desired_height
,
desired_method
,
desired_type
):
desired_method
,
desired_type
):
media_info
=
yield
self
.
media_repo
.
get_remote_media
(
server_name
,
media_id
)
media_info
=
yield
self
.
media_repo
.
get_remote_media
_info
(
server_name
,
media_id
)
thumbnail_infos
=
yield
self
.
store
.
get_remote_media_thumbnails
(
thumbnail_infos
=
yield
self
.
store
.
get_remote_media_thumbnails
(
server_name
,
media_id
,
server_name
,
media_id
,
...
@@ -216,7 +216,7 @@ class ThumbnailResource(Resource):
...
@@ -216,7 +216,7 @@ class ThumbnailResource(Resource):
# TODO: Don't download the whole remote file
# TODO: Don't download the whole remote file
# We should proxy the thumbnail from the remote server instead of
# We should proxy the thumbnail from the remote server instead of
# downloading the remote file and generating our own thumbnails.
# downloading the remote file and generating our own thumbnails.
yield
self
.
media_repo
.
get_remote_media
(
server_name
,
media_id
)
yield
self
.
media_repo
.
get_remote_media
_info
(
server_name
,
media_id
)
thumbnail_infos
=
yield
self
.
store
.
get_remote_media_thumbnails
(
thumbnail_infos
=
yield
self
.
store
.
get_remote_media_thumbnails
(
server_name
,
media_id
,
server_name
,
media_id
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment