Skip to content

Commit 174d00b

Browse files
committed
fix aria2c with both download cases
1 parent efe5463 commit 174d00b

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

koboldcpp.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6505,18 +6505,20 @@ def downloader_internal(input_url, output_filename, capture_output, min_file_siz
65056505
print(f"{output_filename} already exists, using existing file.")
65066506
return output_filename
65076507
print(f"Downloading {input_url}", flush=True)
6508-
dl_success = False
65096508

6509+
dl_success = False
6510+
out_dir = os.path.dirname(os.path.abspath(output_filename)) or os.getcwd()
6511+
out_name = os.path.basename(output_filename)
65106512
try:
65116513
if os.name == 'nt':
65126514
basepath = os.path.abspath(os.path.dirname(__file__))
6513-
a2cexe = (os.path.join(basepath, "aria2c-win.exe"))
6514-
if os.path.exists(a2cexe): #on windows try using embedded a2cexe
6515-
out_dir = os.path.dirname(output_filename)
6516-
out_name = os.path.basename(output_filename)
6515+
a2cexe = os.path.join(basepath, "aria2c-win.exe")
6516+
if os.path.exists(a2cexe): # on windows try using embedded aria2c
65176517
rc = subprocess.run([
6518-
a2cexe, "-x", "16", "-s", "16", "--summary-interval=15", "--console-log-level=error", "--log-level=error",
6519-
"--download-result=default", "--continue=true", "--allow-overwrite=true", "--file-allocation=none", "--max-tries=3",
6518+
a2cexe, "-x", "16", "-s", "16",
6519+
"--summary-interval=15", "--console-log-level=error", "--log-level=error",
6520+
"--download-result=default", "--continue=true", "--allow-overwrite=true",
6521+
"--file-allocation=none", "--max-tries=3",
65206522
"-d", out_dir, "-o", out_name, input_url
65216523
], capture_output=capture_output, text=True, check=True, encoding='utf-8')
65226524
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
65256527

65266528
try:
65276529
if not dl_success and shutil.which("aria2c") is not None:
6528-
out_dir = os.path.dirname(output_filename)
6529-
out_name = os.path.basename(output_filename)
65306530
rc = subprocess.run([
6531-
"aria2c", "-x", "16", "-s", "16", "--summary-interval=15", "--console-log-level=error", "--log-level=error",
6532-
"--download-result=default", "--allow-overwrite=true", "--file-allocation=none", "--max-tries=3",
6531+
"aria2c", "-x", "16", "-s", "16",
6532+
"--summary-interval=15", "--console-log-level=error", "--log-level=error",
6533+
"--download-result=default", "--allow-overwrite=true",
6534+
"--file-allocation=none", "--max-tries=3",
65336535
"-d", out_dir, "-o", out_name, input_url
65346536
], capture_output=capture_output, text=True, check=True, encoding='utf-8')
65356537
dl_success = (rc.returncode == 0 and os.path.exists(output_filename) and os.path.getsize(output_filename) > min_file_size)

0 commit comments

Comments
 (0)