Skip to content

Commit 08c0246

Browse files
committed
prioritize cwd for downloads if its writable
1 parent f508404 commit 08c0246

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

koboldcpp.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6492,9 +6492,14 @@ def downloader_internal(input_url, output_filename, capture_output, min_file_siz
64926492
if "https://huggingface.co/" in input_url and "/blob/main/" in input_url:
64936493
input_url = input_url.replace("/blob/main/", "/resolve/main/")
64946494
if output_filename == "auto":
6495-
exe_dir = os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else __file__)
6496-
filename = os.path.basename(input_url).split('?')[0].split('#')[0]
6497-
output_filename = os.path.join(exe_dir, filename)
6495+
cwd = os.getcwd()
6496+
test_writable = os.access(cwd, os.W_OK)
6497+
if test_writable:
6498+
output_filename = os.path.basename(input_url).split('?')[0].split('#')[0]
6499+
else:
6500+
exe_dir = os.path.dirname(sys.executable if getattr(sys, 'frozen', False) else __file__)
6501+
filename = os.path.basename(input_url).split('?')[0].split('#')[0]
6502+
output_filename = os.path.join(exe_dir, filename)
64986503
incomplete_dl_exist = (os.path.exists(output_filename+".aria2") and os.path.getsize(output_filename+".aria2") > 16)
64996504
if os.path.exists(output_filename) and os.path.getsize(output_filename) > min_file_size and not incomplete_dl_exist:
65006505
print(f"{output_filename} already exists, using existing file.")

0 commit comments

Comments
 (0)