File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -86,8 +86,7 @@ async def synchronize(
8686 )
8787
8888 await self .sync_packages ()
89- if sync_simple_index :
90- self .finalize_sync ()
89+ self .finalize_sync (sync_index_page = sync_simple_index )
9190 return self .altered_packages
9291
9392 def _filter_packages (self ) -> None :
@@ -167,7 +166,7 @@ async def sync_packages(self) -> None:
167166 # TODO Remove this check by following packages_to_sync's typing
168167 self .on_error (e )
169168
170- def finalize_sync (self ) -> None :
169+ def finalize_sync (self , sync_index_page : bool = True ) -> None :
171170 raise NotImplementedError ()
172171
173172 def on_error (self , exception : BaseException , ** kwargs : Dict ) -> None :
@@ -344,8 +343,9 @@ async def process_package(self, package: Package) -> None:
344343 # Cleanup old legacy non PEP 503 Directories created for the Simple API
345344 await self .cleanup_non_pep_503_paths (package )
346345
347- def finalize_sync (self ) -> None :
348- self .sync_index_page ()
346+ def finalize_sync (self , sync_index_page : bool = True ) -> None :
347+ if sync_index_page :
348+ self .sync_index_page ()
349349 if self .need_wrapup :
350350 self .wrapup_successful_sync ()
351351 return None
Original file line number Diff line number Diff line change @@ -297,6 +297,28 @@ async def test_mirror_empty_resume_from_todo_list(mirror: BandersnatchMirror) ->
297297 assert open ("status" ).read () == "20"
298298
299299
300+ @pytest .mark .asyncio
301+ async def test_mirror_sync_package_skip_index (mirror : BandersnatchMirror ) -> None :
302+ mirror .master .all_packages = mock .AsyncMock (return_value = {"foo" : 1 }) # type: ignore
303+ mirror .json_save = True
304+ # Recall bootstrap so we have the json dirs
305+ mirror ._bootstrap ()
306+ await mirror .synchronize (sync_simple_index = False )
307+
308+ assert """\
309+ json{0}foo
310+ last-modified
311+ packages{0}2.7{0}f{0}foo{0}foo.whl
312+ packages{0}any{0}f{0}foo{0}foo.zip
313+ pypi{0}foo{0}json
314+ simple{0}foo{0}index.html""" .format (
315+ sep
316+ ) == utils .find (
317+ mirror .webdir , dirs = False
318+ )
319+ assert open ("status" , "rb" ).read () == b"1"
320+
321+
300322@pytest .mark .asyncio
301323async def test_mirror_sync_package (mirror : BandersnatchMirror ) -> None :
302324 mirror .master .all_packages = mock .AsyncMock (return_value = {"foo" : 1 }) # type: ignore
You can’t perform that action at this time.
0 commit comments