diff --git a/TODO.md b/TODO.md index 6279f724..53947060 100644 --- a/TODO.md +++ b/TODO.md @@ -153,8 +153,6 @@ ## Backend -- Have a `Thubmnail.from_existing_file()` to be called after generating and - and uploading a thumbnail, like the equivalent `Media.from_existing_file()` - Saving the room settings - Refetch profile after manual profile change, don't wait for a room event diff --git a/src/backend/matrix_client.py b/src/backend/matrix_client.py index 96e0d74a..11152861 100644 --- a/src/backend/matrix_client.py +++ b/src/backend/matrix_client.py @@ -471,8 +471,7 @@ class MatrixClient(nio.AsyncClient): thumb_url, _, thumb_crypt_dict = await self.upload( lambda *_: thumb_data, - filename = - f"{path.stem}_sample{''.join(path.suffixes)}", + filename = f"{path.stem}_sample{path.suffix}", filesize = thumb_info.size, encrypt = encrypt, monitor = monitor, @@ -489,6 +488,7 @@ class MatrixClient(nio.AsyncClient): await Thumbnail.from_bytes( self.backend.media_cache, thumb_url, + path.name, thumb_data, wanted_size = (content["info"]["w"], content["info"]["h"]), diff --git a/src/backend/media_cache.py b/src/backend/media_cache.py index b524138a..cba15be8 100644 --- a/src/backend/media_cache.py +++ b/src/backend/media_cache.py @@ -193,13 +193,14 @@ class Media: cls, cache: "MediaCache", mxc: str, + filename: str, data: bytes, overwrite: bool = False, **kwargs, ) -> "Media": """Create a cached file from bytes data and return a `Media` for it.""" - media = cls(cache, mxc, {}, **kwargs) # type: ignore + media = cls(cache, mxc, filename, {}, **kwargs) # type: ignore media.local_path.parent.mkdir(parents=True, exist_ok=True) if not media.local_path.exists() or overwrite: