diff options
author | Erik Johnston <erik@matrix.org> | 2020-10-30 10:55:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-30 10:55:24 +0000 |
commit | 46f4be94b410776ef3f922af2f437eb17631d2fa (patch) | |
tree | c686c30dac2bac97c2b0c05dc2c7e224748de375 /synapse/storage/databases | |
parent | Fix optional parameter in stripped state storage method (#8688) (diff) | |
download | synapse-46f4be94b410776ef3f922af2f437eb17631d2fa.tar.xz |
Fix race for concurrent downloads of remote media. (#8682)
Fixes #6755
Diffstat (limited to 'synapse/storage/databases')
-rw-r--r-- | synapse/storage/databases/main/media_repository.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/synapse/storage/databases/main/media_repository.py b/synapse/storage/databases/main/media_repository.py index daf57675d8..4b2f224718 100644 --- a/synapse/storage/databases/main/media_repository.py +++ b/synapse/storage/databases/main/media_repository.py @@ -452,6 +452,33 @@ class MediaRepositoryStore(MediaRepositoryBackgroundUpdateStore): desc="get_remote_media_thumbnails", ) + async def get_remote_media_thumbnail( + self, origin: str, media_id: str, t_width: int, t_height: int, t_type: str, + ) -> Optional[Dict[str, Any]]: + """Fetch the thumbnail info of given width, height and type. + """ + + return await self.db_pool.simple_select_one( + table="remote_media_cache_thumbnails", + keyvalues={ + "media_origin": origin, + "media_id": media_id, + "thumbnail_width": t_width, + "thumbnail_height": t_height, + "thumbnail_type": t_type, + }, + retcols=( + "thumbnail_width", + "thumbnail_height", + "thumbnail_method", + "thumbnail_type", + "thumbnail_length", + "filesystem_id", + ), + allow_none=True, + desc="get_remote_media_thumbnail", + ) + async def store_remote_media_thumbnail( self, origin, |