From 6213560a0543b11eb007020b044255edaf009d4b Mon Sep 17 00:00:00 2001 From: Abhay Mohandas <80393938+abhay-mohandas@users.noreply.github.com> Date: Tue, 9 Aug 2022 23:45:49 +0530 Subject: Fixes for known issues in the Parallel Download option (#1403) * Adding menu * Working on parallel downloads * error updates * updates * update * Few more updates * bug fixes * More bug fixes * Minor bug fixes * Few changes * Minor changes * Cleaned up add_number_of_parrallel_downloads() and hid it behind --advanced * Forgot one import * Fixed flake8 * Bug fixes * I'm trying... * trying again * trying even more * Bug fixes * Fixed known issues * Code improvements * Few fixes * Minor changes * Minor changes * Trying to fix flake8 Co-authored-by: Anton Hvornum --- archinstall/lib/user_interaction/general_conf.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'archinstall/lib/user_interaction') diff --git a/archinstall/lib/user_interaction/general_conf.py b/archinstall/lib/user_interaction/general_conf.py index 44147afa..a121f368 100644 --- a/archinstall/lib/user_interaction/general_conf.py +++ b/archinstall/lib/user_interaction/general_conf.py @@ -206,15 +206,25 @@ def ask_additional_packages_to_install(pre_set_packages: List[str] = []) -> List return packages -def add_number_of_parrallel_downloads(input_number :Optional[int] = None) -> Optional[int]: - print(_("Enter the number of parallel downloads to be enabled.\n [Default value is 0]")) - while input_number is None: +def add_number_of_parrallel_downloads(input_number :Optional[int] = None) -> Optional[int]: + max_downloads = 5 + print(_(f"This option enables the number of parallel downloads that can occur during installation")) + print(_(f"Enter the number of parallel downloads to be enabled.\n (Enter a value between 1 to {max_downloads})\nNote:")) + print(_(f" - Maximum value : {max_downloads} ( Allows {max_downloads} parallel downloads, allows {max_downloads+1} downloads at a time )")) + print(_(f" - Minimum value : 1 ( Allows 1 parallel download, allows 2 downloads at a time )")) + print(_(f" - Disable/Default : 0 ( Disables parallel downloading, allows only 1 download at a time )")) + + while True: try: - input_number = int(TextInput("> ").run().strip() or 0) + input_number = int(TextInput("[Default value: 0] > ").run().strip() or 0) + if input_number <= 0: + input_number = 0 + elif input_number > max_downloads: + input_number = max_downloads break except: - print(_("Invalid input! Try again with a valid input")) + print(_(f"Invalid input! Try again with a valid input [1 to {max_downloads}, or 0 to disable]")) pacman_conf_path = pathlib.Path("/etc/pacman.conf") with pacman_conf_path.open() as f: @@ -223,7 +233,7 @@ def add_number_of_parrallel_downloads(input_number :Optional[int] = None) -> Opt with pacman_conf_path.open("w") as fwrite: for line in pacman_conf: if "ParallelDownloads" in line: - fwrite.write(f"ParallelDownloads = {input_number}\n") + fwrite.write(f"ParallelDownloads = {input_number+1}\n") if not input_number == 0 else fwrite.write("#ParallelDownloads = 0\n") else: fwrite.write(f"{line}\n") -- cgit v1.2.3-70-g09d2