Fix loading m.image events in encrypted rooms
Fix bug introduced in 11fb32: When loading an encrypted thumbnail, QML lacks the decryption dict for half a second at first. When calling python like this, python calls the wrong matrix API for fetching the encrypted thumbnail, and the added retry code would be forever stuck. The retry code has been moved to QML, and now works for all HImage.
This commit is contained in:
@@ -12,7 +12,6 @@ from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, Any, DefaultDict, Dict, Optional
|
||||
from urllib.parse import urlparse
|
||||
from .errors import MatrixError
|
||||
|
||||
from PIL import Image as PILImage
|
||||
|
||||
@@ -134,20 +133,8 @@ class Media:
|
||||
async def create(self) -> Path:
|
||||
"""Download and cache the media file to disk."""
|
||||
|
||||
retries = 0
|
||||
|
||||
while True:
|
||||
try:
|
||||
async with CONCURRENT_DOWNLOADS_LIMIT:
|
||||
data = await self._get_remote_data()
|
||||
except MatrixError as err:
|
||||
if err.http_code != 404 and err.http_code < 500:
|
||||
raise
|
||||
else:
|
||||
break
|
||||
|
||||
await asyncio.sleep(min(30, 0.2 * (2 ** (min(1000, retries) - 1))))
|
||||
retries += 1
|
||||
async with CONCURRENT_DOWNLOADS_LIMIT:
|
||||
data = await self._get_remote_data()
|
||||
|
||||
self.local_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
Reference in New Issue
Block a user