mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 09:35:45 +03:00
Update storage provider interface
This commit is contained in:
parent
cdbe676bc4
commit
760e6c61e6
2 changed files with 2 additions and 10 deletions
|
@ -227,7 +227,7 @@ class MediaStorage:
|
||||||
|
|
||||||
for provider in self.storage_providers:
|
for provider in self.storage_providers:
|
||||||
for path in paths:
|
for path in paths:
|
||||||
res: Any = await provider.fetch(path, file_info, media_info, federation)
|
res: Any = await provider.fetch(path, file_info)
|
||||||
if res:
|
if res:
|
||||||
logger.debug("Streaming %s from %s", path, provider)
|
logger.debug("Streaming %s from %s", path, provider)
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -60,8 +60,6 @@ class StorageProvider(metaclass=abc.ABCMeta):
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str,
|
||||||
file_info: FileInfo,
|
file_info: FileInfo,
|
||||||
media_info: Optional[LocalMedia] = None,
|
|
||||||
federation: bool = False,
|
|
||||||
) -> Optional[Responder]:
|
) -> Optional[Responder]:
|
||||||
"""Attempt to fetch the file described by file_info and stream it
|
"""Attempt to fetch the file described by file_info and stream it
|
||||||
into writer.
|
into writer.
|
||||||
|
@ -69,8 +67,6 @@ class StorageProvider(metaclass=abc.ABCMeta):
|
||||||
Args:
|
Args:
|
||||||
path: Relative path of file in local cache
|
path: Relative path of file in local cache
|
||||||
file_info: The metadata of the file.
|
file_info: The metadata of the file.
|
||||||
media_info: metadata of the media item
|
|
||||||
federation: Whether the requested media is for a federation request
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Returns a Responder if the provider has the file, otherwise returns None.
|
Returns a Responder if the provider has the file, otherwise returns None.
|
||||||
|
@ -137,8 +133,6 @@ class StorageProviderWrapper(StorageProvider):
|
||||||
self,
|
self,
|
||||||
path: str,
|
path: str,
|
||||||
file_info: FileInfo,
|
file_info: FileInfo,
|
||||||
media_info: Optional[LocalMedia] = None,
|
|
||||||
federation: bool = False,
|
|
||||||
) -> Optional[Responder]:
|
) -> Optional[Responder]:
|
||||||
if file_info.url_cache:
|
if file_info.url_cache:
|
||||||
# Files in the URL preview cache definitely aren't stored here,
|
# Files in the URL preview cache definitely aren't stored here,
|
||||||
|
@ -147,9 +141,7 @@ class StorageProviderWrapper(StorageProvider):
|
||||||
|
|
||||||
# store_file is supposed to return an Awaitable, but guard
|
# store_file is supposed to return an Awaitable, but guard
|
||||||
# against improper implementations.
|
# against improper implementations.
|
||||||
return await maybe_awaitable(
|
return await maybe_awaitable(self.backend.fetch(path, file_info))
|
||||||
self.backend.fetch(path, file_info, media_info, federation)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class FileStorageProviderBackend(StorageProvider):
|
class FileStorageProviderBackend(StorageProvider):
|
||||||
|
|
Loading…
Reference in a new issue