From e45f2c9d2d74d8c19481194226531cbda344de32 Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 6 Nov 2019 06:51:55 -0400 Subject: [PATCH] Fix thumbnail API error when QML gives float sizes --- TODO.md | 1 + src/python/media_cache.py | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index ad907ca0..9b65148d 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ - Media - SVG uploads - Uploading progress bar (+local echo) + - Text bubbles theming - Directly create cache files for our uploads before actually uploading - Downloading - Bottom/top bar diff --git a/src/python/media_cache.py b/src/python/media_cache.py index 0a17d048..7a998988 100644 --- a/src/python/media_cache.py +++ b/src/python/media_cache.py @@ -194,6 +194,7 @@ class Thumbnail(Media): ) if isinstance(resp, (nio.DownloadError, nio.ThumbnailError)): + import remote_pdb; remote_pdb.RemotePdb("127.0.0.1", 4444).set_trace() raise DownloadFailed(resp.message, resp.status_code) decrypted = await self._decrypt(resp.body) @@ -227,5 +228,8 @@ class MediaCache: self, mxc: str, width: int, height: int, crypt_dict: CryptDict = None, ) -> str: - thumb = Thumbnail(self, mxc, None, crypt_dict, (width, height)) + thumb = Thumbnail( + # QML sometimes pass float sizes, which matrix API doesn't like. + self, mxc, None, crypt_dict, (round(width), round(height)), + ) return str(await thumb.get())