diff --git a/synapse/rest/media/v1/download_resource.py b/synapse/rest/media/v1/download_resource.py
index 3ed219ae43..48f4433155 100644
--- a/synapse/rest/media/v1/download_resource.py
+++ b/synapse/rest/media/v1/download_resource.py
@@ -51,7 +51,8 @@ class DownloadResource(DirectServeJsonResource):
b" object-src 'self';",
)
request.setHeader(
- b"Referrer-Policy", b"no-referrer",
+ b"Referrer-Policy",
+ b"no-referrer",
)
server_name, media_id, name = parse_media_id(request)
if server_name == self.server_name:
diff --git a/synapse/rest/media/v1/media_repository.py b/synapse/rest/media/v1/media_repository.py
index 635bccf775..a0162d4255 100644
--- a/synapse/rest/media/v1/media_repository.py
+++ b/synapse/rest/media/v1/media_repository.py
@@ -325,7 +325,10 @@ class MediaRepository:
# Failed to find the file anywhere, lets download it.
try:
- media_info = await self._download_remote_file(server_name, media_id,)
+ media_info = await self._download_remote_file(
+ server_name,
+ media_id,
+ )
except SynapseError:
raise
except Exception as e:
@@ -351,7 +354,11 @@ class MediaRepository:
responder = await self.media_storage.fetch_media(file_info)
return responder, media_info
- async def _download_remote_file(self, server_name: str, media_id: str,) -> dict:
+ async def _download_remote_file(
+ self,
+ server_name: str,
+ media_id: str,
+ ) -> dict:
"""Attempt to download the remote file from the given server name,
using the given file_id as the local id.
@@ -773,7 +780,11 @@ class MediaRepository:
)
except Exception as e:
thumbnail_exists = await self.store.get_remote_media_thumbnail(
- server_name, media_id, t_width, t_height, t_type,
+ server_name,
+ media_id,
+ t_width,
+ t_height,
+ t_type,
)
if not thumbnail_exists:
raise e
@@ -832,7 +843,10 @@ class MediaRepository:
return await self._remove_local_media_from_disk([media_id])
async def delete_old_local_media(
- self, before_ts: int, size_gt: int = 0, keep_profiles: bool = True,
+ self,
+ before_ts: int,
+ size_gt: int = 0,
+ keep_profiles: bool = True,
) -> Tuple[List[str], int]:
"""
Delete local or remote media from this server by size and timestamp. Removes
@@ -849,7 +863,9 @@ class MediaRepository:
A tuple of (list of deleted media IDs, total deleted media IDs).
"""
old_media = await self.store.get_local_media_before(
- before_ts, size_gt, keep_profiles,
+ before_ts,
+ size_gt,
+ keep_profiles,
)
return await self._remove_local_media_from_disk(old_media)
diff --git a/synapse/rest/media/v1/media_storage.py b/synapse/rest/media/v1/media_storage.py
index aba6d689a8..1057e638be 100644
--- a/synapse/rest/media/v1/media_storage.py
+++ b/synapse/rest/media/v1/media_storage.py
@@ -85,8 +85,7 @@ class MediaStorage:
return fname
async def write_to_file(self, source: IO, output: IO):
- """Asynchronously write the `source` to `output`.
- """
+ """Asynchronously write the `source` to `output`."""
await defer_to_thread(self.reactor, _write_file_synchronously, source, output)
@contextlib.contextmanager
@@ -342,8 +341,7 @@ class ReadableFileWrapper:
path = attr.ib(type=str)
async def write_chunks_to(self, callback: Callable[[bytes], None]):
- """Reads the file in chunks and calls the callback with each chunk.
- """
+ """Reads the file in chunks and calls the callback with each chunk."""
with open(self.path, "rb") as file:
while True:
diff --git a/synapse/rest/media/v1/preview_url_resource.py b/synapse/rest/media/v1/preview_url_resource.py
index ae53b1d23f..6104ef4e46 100644
--- a/synapse/rest/media/v1/preview_url_resource.py
+++ b/synapse/rest/media/v1/preview_url_resource.py
@@ -580,8 +580,7 @@ class PreviewUrlResource(DirectServeJsonResource):
)
async def _expire_url_cache_data(self) -> None:
- """Clean up expired url cache content, media and thumbnails.
- """
+ """Clean up expired url cache content, media and thumbnails."""
# TODO: Delete from backup media store
assert self._worker_run_media_background_jobs
|