Skip to content

Commit

Permalink
Parallel downloads (#1952)
Browse files Browse the repository at this point in the history
* refactor: remove max_downloads limit

* Update parallel downloads

* Update parallel downloads
  • Loading branch information
ComicShrimp authored Jul 31, 2023
1 parent 7dd95f8 commit 9cbb2b7
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions archinstall/lib/interactions/general_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,23 +165,20 @@ def read_packages(p: List = []) -> list:


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(str(_("Enter the number of parallel downloads to be enabled.\n (Enter a value between 1 to {})\nNote:")).format(max_downloads))
print(str(_(" - Maximum value : {} ( Allows {} parallel downloads, allows {} downloads at a time )")).format(max_downloads, max_downloads, max_downloads + 1))
print(_(" - Minimum value : 1 ( Allows 1 parallel download, allows 2 downloads at a time )"))
print(_(" - Disable/Default : 0 ( Disables parallel downloading, allows only 1 download at a time )"))
max_recommended = 5
print(_(f"This option enables the number of parallel downloads that can occur during package downloads"))
print(_("Enter the number of parallel downloads to be enabled.\n\nNote:\n"))
print(str(_(" - Maximum recommended value : {} ( Allows {} parallel downloads at a time )")).format(max_recommended, max_recommended))
print(_(" - Disable/Default : 0 ( Disables parallel downloading, allows only 1 download at a time )\n"))

while True:
try:
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(str(_("Invalid input! Try again with a valid input [1 to {}, or 0 to disable]")).format(max_downloads))
print(str(_("Invalid input! Try again with a valid input [or 0 to disable]")).format(max_recommended))

pacman_conf_path = pathlib.Path("/etc/pacman.conf")
with pacman_conf_path.open() as f:
Expand All @@ -190,7 +187,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+1}\n") if not input_number == 0 else fwrite.write("#ParallelDownloads = 0\n")
fwrite.write(f"ParallelDownloads = {input_number}\n") if not input_number == 0 else fwrite.write("#ParallelDownloads = 0\n")
else:
fwrite.write(f"{line}\n")

Expand Down

0 comments on commit 9cbb2b7

Please sign in to comment.