Aria2c: Fix shutdown condition edge condition when URLs > 1000

`stopped_downloads` is capped to just 1000 objects even though I asked for 999999 downloads, so if aria2c is downloading more than 1000 URLs the count of stopped downloads will never match the count of download URLs and never stop.
This commit is contained in:
rlaphoenix 2024-02-17 23:27:38 +00:00
parent d65d29efa3
commit 1b76e8ee28
1 changed files with 11 additions and 8 deletions

View File

@ -201,13 +201,15 @@ def download(
caller=partial(rpc_session.post, url=rpc_uri),
secret=rpc_secret,
method="aria2.getGlobalStat"
)
number_stopped = int(global_stats["numStoppedTotal"])
if global_stats:
yield dict(
completed=number_stopped,
downloaded=f"{filesize.decimal(int(global_stats['downloadSpeed']))}/s"
)
) or {}
number_stopped = int(global_stats.get("numStoppedTotal", 0))
download_speed = int(global_stats.get("downloadSpeed", -1))
if number_stopped:
yield dict(completed=number_stopped)
if download_speed != -1:
yield dict(downloaded=f"{filesize.decimal(download_speed)}/s")
stopped_downloads: list[dict[str, Any]] = rpc(
caller=partial(rpc_session.post, url=rpc_uri),
@ -215,6 +217,7 @@ def download(
method="aria2.tellStopped",
params=[0, 999999]
) or []
for dl in stopped_downloads:
if dl["status"] == "error":
used_uri = next(
@ -233,7 +236,7 @@ def download(
console.log(Text.from_ansi("\n[Aria2c]: " + error_pretty))
raise ValueError(error)
if len(stopped_downloads) == len(urls):
if number_stopped == len(urls):
rpc(
caller=partial(rpc_session.post, url=rpc_uri),
secret=rpc_secret,