From 174d00bb74e37fa4cf02898ec59beafa63a330d3 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 22 Sep 2025 21:47:08 +0800 Subject: [PATCH] fix aria2c with both download cases --- koboldcpp.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/koboldcpp.py b/koboldcpp.py index 471481c68..9f799e8e8 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -6505,18 +6505,20 @@ def downloader_internal(input_url, output_filename, capture_output, min_file_siz print(f"{output_filename} already exists, using existing file.") return output_filename print(f"Downloading {input_url}", flush=True) - dl_success = False + dl_success = False + out_dir = os.path.dirname(os.path.abspath(output_filename)) or os.getcwd() + out_name = os.path.basename(output_filename) try: if os.name == 'nt': basepath = os.path.abspath(os.path.dirname(__file__)) - a2cexe = (os.path.join(basepath, "aria2c-win.exe")) - if os.path.exists(a2cexe): #on windows try using embedded a2cexe - out_dir = os.path.dirname(output_filename) - out_name = os.path.basename(output_filename) + a2cexe = os.path.join(basepath, "aria2c-win.exe") + if os.path.exists(a2cexe): # on windows try using embedded aria2c rc = subprocess.run([ - a2cexe, "-x", "16", "-s", "16", "--summary-interval=15", "--console-log-level=error", "--log-level=error", - "--download-result=default", "--continue=true", "--allow-overwrite=true", "--file-allocation=none", "--max-tries=3", + a2cexe, "-x", "16", "-s", "16", + "--summary-interval=15", "--console-log-level=error", "--log-level=error", + "--download-result=default", "--continue=true", "--allow-overwrite=true", + "--file-allocation=none", "--max-tries=3", "-d", out_dir, "-o", out_name, input_url ], capture_output=capture_output, text=True, check=True, encoding='utf-8') dl_success = (rc.returncode == 0 and os.path.exists(output_filename) and os.path.getsize(output_filename) > min_file_size) @@ -6525,11 +6527,11 @@ def downloader_internal(input_url, output_filename, capture_output, min_file_siz try: if not dl_success and shutil.which("aria2c") is not None: - out_dir = os.path.dirname(output_filename) - out_name = os.path.basename(output_filename) rc = subprocess.run([ - "aria2c", "-x", "16", "-s", "16", "--summary-interval=15", "--console-log-level=error", "--log-level=error", - "--download-result=default", "--allow-overwrite=true", "--file-allocation=none", "--max-tries=3", + "aria2c", "-x", "16", "-s", "16", + "--summary-interval=15", "--console-log-level=error", "--log-level=error", + "--download-result=default", "--allow-overwrite=true", + "--file-allocation=none", "--max-tries=3", "-d", out_dir, "-o", out_name, input_url ], capture_output=capture_output, text=True, check=True, encoding='utf-8') dl_success = (rc.returncode == 0 and os.path.exists(output_filename) and os.path.getsize(output_filename) > min_file_size)