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
b30cd5b1
Commit
b30cd5b1
authored
7 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Remove dead code related to default thumbnails
parent
a767f06e
Branches
Branches containing commit
Tags
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/thumbnail_resource.py
+3
-73
3 additions, 73 deletions
synapse/rest/media/v1/thumbnail_resource.py
synapse/storage/media_repository.py
+0
-3
0 additions, 3 deletions
synapse/storage/media_repository.py
with
3 additions
and
76 deletions
synapse/rest/media/v1/thumbnail_resource.py
+
3
−
73
View file @
b30cd5b1
...
@@ -85,11 +85,6 @@ class ThumbnailResource(Resource):
...
@@ -85,11 +85,6 @@ class ThumbnailResource(Resource):
respond_404
(
request
)
respond_404
(
request
)
return
return
# if media_info["media_type"] == "image/svg+xml":
# file_path = self.filepaths.local_media_filepath(media_id)
# yield respond_with_file(request, media_info["media_type"], file_path)
# return
thumbnail_infos
=
yield
self
.
store
.
get_local_media_thumbnails
(
media_id
)
thumbnail_infos
=
yield
self
.
store
.
get_local_media_thumbnails
(
media_id
)
if
thumbnail_infos
:
if
thumbnail_infos
:
...
@@ -114,9 +109,7 @@ class ThumbnailResource(Resource):
...
@@ -114,9 +109,7 @@ class ThumbnailResource(Resource):
yield
respond_with_file
(
request
,
t_type
,
file_path
)
yield
respond_with_file
(
request
,
t_type
,
file_path
)
else
:
else
:
yield
self
.
_respond_default_thumbnail
(
respond_404
(
request
)
request
,
media_info
,
width
,
height
,
method
,
m_type
,
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
_select_or_generate_local_thumbnail
(
self
,
request
,
media_id
,
desired_width
,
def
_select_or_generate_local_thumbnail
(
self
,
request
,
media_id
,
desired_width
,
...
@@ -128,11 +121,6 @@ class ThumbnailResource(Resource):
...
@@ -128,11 +121,6 @@ class ThumbnailResource(Resource):
respond_404
(
request
)
respond_404
(
request
)
return
return
# if media_info["media_type"] == "image/svg+xml":
# file_path = self.filepaths.local_media_filepath(media_id)
# yield respond_with_file(request, media_info["media_type"], file_path)
# return
thumbnail_infos
=
yield
self
.
store
.
get_local_media_thumbnails
(
media_id
)
thumbnail_infos
=
yield
self
.
store
.
get_local_media_thumbnails
(
media_id
)
for
info
in
thumbnail_infos
:
for
info
in
thumbnail_infos
:
t_w
=
info
[
"
thumbnail_width
"
]
==
desired_width
t_w
=
info
[
"
thumbnail_width
"
]
==
desired_width
...
@@ -166,10 +154,7 @@ class ThumbnailResource(Resource):
...
@@ -166,10 +154,7 @@ class ThumbnailResource(Resource):
if
file_path
:
if
file_path
:
yield
respond_with_file
(
request
,
desired_type
,
file_path
)
yield
respond_with_file
(
request
,
desired_type
,
file_path
)
else
:
else
:
yield
self
.
_respond_default_thumbnail
(
respond_404
(
request
)
request
,
media_info
,
desired_width
,
desired_height
,
desired_method
,
desired_type
,
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
_select_or_generate_remote_thumbnail
(
self
,
request
,
server_name
,
media_id
,
def
_select_or_generate_remote_thumbnail
(
self
,
request
,
server_name
,
media_id
,
...
@@ -177,11 +162,6 @@ class ThumbnailResource(Resource):
...
@@ -177,11 +162,6 @@ class ThumbnailResource(Resource):
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
(
server_name
,
media_id
)
# if media_info["media_type"] == "image/svg+xml":
# file_path = self.filepaths.remote_media_filepath(server_name, media_id)
# yield respond_with_file(request, media_info["media_type"], file_path)
# return
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
,
)
)
...
@@ -213,23 +193,13 @@ class ThumbnailResource(Resource):
...
@@ -213,23 +193,13 @@ class ThumbnailResource(Resource):
if
file_path
:
if
file_path
:
yield
respond_with_file
(
request
,
desired_type
,
file_path
)
yield
respond_with_file
(
request
,
desired_type
,
file_path
)
else
:
else
:
yield
self
.
_respond_default_thumbnail
(
respond_404
(
request
)
request
,
media_info
,
desired_width
,
desired_height
,
desired_method
,
desired_type
,
)
@defer.inlineCallbacks
@defer.inlineCallbacks
def
_respond_remote_thumbnail
(
self
,
request
,
server_name
,
media_id
,
width
,
def
_respond_remote_thumbnail
(
self
,
request
,
server_name
,
media_id
,
width
,
height
,
method
,
m_type
):
height
,
method
,
m_type
):
# 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.
# We should proxy the thumbnail from the remote server instead.
media_info
=
yield
self
.
media_repo
.
get_remote_media
(
server_name
,
media_id
)
# if media_info["media_type"] == "image/svg+xml":
# file_path = self.filepaths.remote_media_filepath(server_name, media_id)
# yield respond_with_file(request, media_info["media_type"], file_path)
# return
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
,
)
)
...
@@ -250,47 +220,7 @@ class ThumbnailResource(Resource):
...
@@ -250,47 +220,7 @@ class ThumbnailResource(Resource):
)
)
yield
respond_with_file
(
request
,
t_type
,
file_path
,
t_length
)
yield
respond_with_file
(
request
,
t_type
,
file_path
,
t_length
)
else
:
else
:
yield
self
.
_respond_default_thumbnail
(
request
,
media_info
,
width
,
height
,
method
,
m_type
,
)
@defer.inlineCallbacks
def
_respond_default_thumbnail
(
self
,
request
,
media_info
,
width
,
height
,
method
,
m_type
):
# XXX: how is this meant to work? store.get_default_thumbnails
# appears to always return [] so won't this always 404?
media_type
=
media_info
[
"
media_type
"
]
top_level_type
=
media_type
.
split
(
"
/
"
)[
0
]
sub_type
=
media_type
.
split
(
"
/
"
)[
-
1
].
split
(
"
;
"
)[
0
]
thumbnail_infos
=
yield
self
.
store
.
get_default_thumbnails
(
top_level_type
,
sub_type
,
)
if
not
thumbnail_infos
:
thumbnail_infos
=
yield
self
.
store
.
get_default_thumbnails
(
top_level_type
,
"
_default
"
,
)
if
not
thumbnail_infos
:
thumbnail_infos
=
yield
self
.
store
.
get_default_thumbnails
(
"
_default
"
,
"
_default
"
,
)
if
not
thumbnail_infos
:
respond_404
(
request
)
respond_404
(
request
)
return
thumbnail_info
=
self
.
_select_thumbnail
(
width
,
height
,
"
crop
"
,
m_type
,
thumbnail_infos
)
t_width
=
thumbnail_info
[
"
thumbnail_width
"
]
t_height
=
thumbnail_info
[
"
thumbnail_height
"
]
t_type
=
thumbnail_info
[
"
thumbnail_type
"
]
t_method
=
thumbnail_info
[
"
thumbnail_method
"
]
t_length
=
thumbnail_info
[
"
thumbnail_length
"
]
file_path
=
self
.
filepaths
.
default_thumbnail
(
top_level_type
,
sub_type
,
t_width
,
t_height
,
t_type
,
t_method
,
)
yield
respond_with_file
(
request
,
t_type
,
file_path
,
t_length
)
def
_select_thumbnail
(
self
,
desired_width
,
desired_height
,
desired_method
,
def
_select_thumbnail
(
self
,
desired_width
,
desired_height
,
desired_method
,
desired_type
,
thumbnail_infos
):
desired_type
,
thumbnail_infos
):
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/media_repository.py
+
0
−
3
View file @
b30cd5b1
...
@@ -29,9 +29,6 @@ class MediaRepositoryStore(BackgroundUpdateStore):
...
@@ -29,9 +29,6 @@ class MediaRepositoryStore(BackgroundUpdateStore):
where_clause
=
'
url_cache IS NOT NULL
'
,
where_clause
=
'
url_cache IS NOT NULL
'
,
)
)
def
get_default_thumbnails
(
self
,
top_level_type
,
sub_type
):
return
[]
def
get_local_media
(
self
,
media_id
):
def
get_local_media
(
self
,
media_id
):
"""
Get the metadata for a local piece of media
"""
Get the metadata for a local piece of media
Returns:
Returns:
...
...
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