From 08c0246f24fb7714f4740bfc755f6d52d2e29243 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Mon, 22 Sep 2025 13:47:50 +0800 Subject: [PATCH] prioritize cwd for downloads if its writable --- koboldcpp.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/koboldcpp.py b/koboldcpp.py index 82f2fd873..f86d16e44 100644 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -6492,9 +6492,14 @@ def downloader_internal(input_url, output_filename, capture_output, min_file_siz if "https://huggingface.co/" in input_url and "/blob/main/" in input_url: input_url = input_url.replace("/blob/main/", "/resolve/main/") if output_filename == "auto": - exe_dir = os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else __file__) - filename = os.path.basename(input_url).split('?')[0].split('#')[0] - output_filename = os.path.join(exe_dir, filename) + cwd = os.getcwd() + test_writable = os.access(cwd, os.W_OK) + if test_writable: + output_filename = os.path.basename(input_url).split('?')[0].split('#')[0] + else: + exe_dir = os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else __file__) + filename = os.path.basename(input_url).split('?')[0].split('#')[0] + output_filename = os.path.join(exe_dir, filename) incomplete_dl_exist = (os.path.exists(output_filename+".aria2") and os.path.getsize(output_filename+".aria2") > 16) if os.path.exists(output_filename) and os.path.getsize(output_filename) > min_file_size and not incomplete_dl_exist: print(f"{output_filename} already exists, using existing file.")