4646)
4747from azul .service import (
4848 BadArgumentException ,
49- FileMirrorUriFunc ,
5049 FileUrlFunc ,
5150 Filters ,
5251)
@@ -80,8 +79,8 @@ def __init__(self, entity_type: str, entity_id: str):
8079@attrs .frozen (auto_attribs = True , kw_only = True )
8180class SearchResponseStage (_ElasticsearchStage [ResponseTriple , MutableJSON ],
8281 metaclass = ABCMeta ):
82+ service : 'RepositoryService'
8383 file_url_func : FileUrlFunc
84- file_mirror_uri_func : FileMirrorUriFunc
8584
8685 def prepare_request (self , request : Search ) -> Search :
8786 return request
@@ -105,7 +104,7 @@ def _file_url(self, *, uuid: str, version: str, drs_uri: str | None) -> str | No
105104 def _file_mirror_uri (self , file : JSON ) -> str | None :
106105 file = self .plugin .file_class .from_index (file )
107106 if BaseMirrorService .may_mirror (self .catalog , file .size ):
108- return self .file_mirror_uri_func (file )
107+ return self .service . mirror_service ( self . catalog ). mirror_uri (file )
109108 else :
110109 return None
111110
@@ -133,7 +132,6 @@ def search(self,
133132 catalog : CatalogName ,
134133 entity_type : str ,
135134 file_url_func : FileUrlFunc ,
136- file_mirror_uri_func : FileMirrorUriFunc ,
137135 item_id : str | None ,
138136 filters : Filters ,
139137 pagination : Pagination
@@ -148,8 +146,6 @@ def search(self,
148146 :param file_url_func: A function that is used only when getting a *list* of files data.
149147 It creates the files URL based on info from the request. It should have the type
150148 signature `(uuid: str, **params) -> str`
151- :param file_mirror_uri_func: Like `file_url_func`, but creates URIs to
152- where the files are mirrored. It should have the type signature `(File) -> str`.
153149 :return: The Elasticsearch JSON response
154150 """
155151 if item_id is not None :
@@ -161,8 +157,7 @@ def search(self,
161157 pagination = pagination ,
162158 aggregate = item_id is None ,
163159 entity_type = entity_type ,
164- file_url_func = file_url_func ,
165- file_mirror_uri_func = file_mirror_uri_func )
160+ file_url_func = file_url_func )
166161
167162 special_fields = self .metadata_plugin (catalog ).special_fields
168163 for hit in response ['hits' ]:
@@ -182,8 +177,7 @@ def _search(self,
182177 aggregate : bool ,
183178 filters : Filters ,
184179 pagination : Pagination ,
185- file_url_func : FileUrlFunc ,
186- file_mirror_uri_func : FileMirrorUriFunc ,
180+ file_url_func : FileUrlFunc
187181 ) -> MutableJSON :
188182 """
189183 This function does the whole transformation process. It takes the path
@@ -242,8 +236,7 @@ def _search(self,
242236 chain = response_stage_cls (service = self ,
243237 catalog = catalog ,
244238 entity_type = entity_type ,
245- file_url_func = file_url_func ,
246- file_mirror_uri_func = file_mirror_uri_func ).wrap (chain )
239+ file_url_func = file_url_func ).wrap (chain )
247240
248241 request = self .create_request (catalog , entity_type )
249242 request = chain .prepare_request (request )
0 commit comments