mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
index: download_repo_index_v2() uses mirrors
test_download_repo_index_v2_url_parsing is no longer needed, since all the things it tested are now handled in test_download_repo_index_v2
This commit is contained in:
parent
2e3f6d273a
commit
59fcfa5dec
6 changed files with 119 additions and 81 deletions
|
|
@ -61,7 +61,7 @@ from base64 import urlsafe_b64encode
|
|||
from binascii import hexlify
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from queue import Queue
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
from urllib.parse import urlparse, urlsplit, urlunparse
|
||||
from zipfile import ZipFile
|
||||
|
||||
import fdroidserver.metadata
|
||||
|
|
@ -619,6 +619,23 @@ def parse_mirrors_config(mirrors):
|
|||
raise TypeError(_('only accepts strings, lists, and tuples'))
|
||||
|
||||
|
||||
def get_mirrors(url, filename=None):
|
||||
"""Get list of dict entries for mirrors, appending filename if provided."""
|
||||
# TODO use cached index if it exists
|
||||
if isinstance(url, str):
|
||||
url = urlsplit(url)
|
||||
|
||||
if url.netloc == 'f-droid.org':
|
||||
mirrors = FDROIDORG_MIRRORS
|
||||
else:
|
||||
mirrors = parse_mirrors_config(url.geturl())
|
||||
|
||||
if filename:
|
||||
return append_filename_to_mirrors(filename, mirrors)
|
||||
else:
|
||||
return mirrors
|
||||
|
||||
|
||||
def append_filename_to_mirrors(filename, mirrors):
|
||||
"""Append the filename to all "url" entries in the mirrors dict."""
|
||||
appended = copy.deepcopy(mirrors)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue