Optimize get_existing_hrefs for fast path (json file exists)

Related: #4
This commit is contained in:
taoky 2024-08-27 19:20:20 +08:00
parent 799a477336
commit 9e57eb6f46

View File

@ -246,15 +246,15 @@ def get_existing_hrefs(package_simple_path: Path) -> Optional[list[str]]:
Priority: index.v1_json -> index.html
"""
if not package_simple_path.exists():
return None
json_file = package_simple_path / "index.v1_json"
html_file = package_simple_path / "index.html"
if json_file.exists():
try:
return get_package_urls_from_index_json(json_file)
if html_file.exists():
return get_package_urls_from_index_html(html_file)
return None
except FileNotFoundError:
try:
return get_package_urls_from_index_html(html_file)
except FileNotFoundError:
return None
class CustomXMLRPCTransport(xmlrpc.client.Transport):