Commit ed367c4d authored by Frede Hundewadt's avatar Frede Hundewadt

fix for issue #140 - version 4.11.5

parent 1d6bcc40
# Change Log
All notable changes to this project will be documented in this file.
## [4.11.5] 2018-07-24
* Fix for [#140](https://gitlab.manjaro.org/applications/pacman-mirrors/issues/140)
* Fix issue for when user had configured protocol limitations - servers with invalid certificates was still written to the mirrorlist.
## [4.11.4] 2018-07-23
* Fix for [#139](https://gitlab.manjaro.org/applications/pacman-mirrors/issues/139)
* Fixed interactive mirrorlist still containing https on invalid certificate
......
__version__ = "4.11.4"
__version__ = "4.11.5"
......@@ -23,15 +23,14 @@ from pacman_mirrors.constants import txt
from pacman_mirrors.functions import util
def translate_interactive_to_pool(custom_selection, mirror_pool, config):
def translate_interactive_to_pool(custom_mirrors, mirror_pool, config):
"""
Translate the interactive selection back to mirror pool
:param custom_selection: the custom selection
:param custom_mirrors: the custom mirror selection
:param mirror_pool: the default mirror pool
:param config: the active pacman-mirrors configuration
:return: custom mirror pool and mirrors for mirror list generation
"""
# return lists
custom_mirror_pool = []
mirror_list = []
......@@ -39,59 +38,28 @@ def translate_interactive_to_pool(custom_selection, mirror_pool, config):
try:
_ = mirror_pool[0]
mirror_url = util.get_server_location_from_url(mirror["url"])
for current in custom_selection:
for custom_mirror in custom_mirrors:
try:
"""
url without protocol
"""
url = util.get_server_location_from_url(current["url"])
"""
protocol without url
"""
protocol = util.get_protocol_from_url(current["url"])
if url == mirror_url:
"""
Create working copy
"""
work_mirror = {
"country": mirror["country"],
"branches": mirror["branches"],
"protocols": [],
"resp_time": mirror["resp_time"],
"last_sync": mirror["last_sync"],
"url": mirror["url"]
}
"""
Append to custom mirror pool
"""
custom_mirror_pool.append({
custom_url = util.get_server_location_from_url(custom_mirror["url"])
custom_protocol = util.get_protocol_from_url(custom_mirror["url"])
if custom_url == mirror_url:
pool_mirror = {
"country": mirror["country"],
"protocols": mirror["protocols"],
"url": mirror["url"]
})
try:
"""
If a user selection of protocols exist in configuration
Replace the mirrors protocols with selection
"""
_ = config["protocols"][0]
work_mirror["protocols"] = config["protocols"]
except IndexError:
pass
for idx, proto in enumerate(mirror["protocols"]):
"""
Generate a mirror by adding selected protocol to the server
Avoid duplicating the protocols by keepin an internal set of protocols
The custom_protocols set is used for that purpose
"""
if proto == protocol:
work_mirror["protocols"].append(proto)
"""
Add to the mirrorlist
"""
mirror_list.append(work_mirror)
"url": mirror["url"],
}
custom_mirror_pool.append(pool_mirror)
custom_mirror["branches"] = mirror["branches"]
custom_mirror["protocols"] = [custom_protocol]
for m in mirror_list:
if m["url"].endswith(custom_url):
m["protocols"].append(custom_protocol)
if custom_mirror not in mirror_list:
mirror_list.append(custom_mirror)
except KeyError:
print(".: {} {}! {}!".format(txt.WRN_CLR, txt.HOUSTON, txt.CUSTOM_POOL_EMPTY))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment