Skip to content

Commit 07a96d6

Browse files
committed
try to ensure correct file extension
1 parent 6e086bd commit 07a96d6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

koboldcpp.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3048,7 +3048,7 @@ def do_POST(self):
30483048
if targetfile and targetfile!="":
30493049
dirpath = os.path.abspath(args.admindir)
30503050
targetfilepath = os.path.join(dirpath, targetfile)
3051-
opts = [f for f in os.listdir(dirpath) if (f.endswith(".kcpps") or f.endswith(".kcppt") or f.endswith(".gguf")) and os.path.isfile(os.path.join(dirpath, f))]
3051+
opts = [f for f in os.listdir(dirpath) if (f.lower().endswith(".kcpps") or f.lower().endswith(".kcppt") or f.lower().endswith(".gguf")) and os.path.isfile(os.path.join(dirpath, f))]
30523052
if targetfile in opts and os.path.exists(targetfilepath):
30533053
print(f"Admin: Received request to reload config to {targetfile}")
30543054
global_memory["restart_target"] = targetfile
@@ -4268,7 +4268,8 @@ def kcpp_export_template():
42684268
if not filename:
42694269
return
42704270
filenamestr = str(filename).strip()
4271-
filenamestr = f"{filenamestr}.kcppt" if ".kcppt" not in filenamestr.lower() else filenamestr
4271+
if not filenamestr.endswith(".kcppt"):
4272+
filenamestr += ".kcpps"
42724273
file = open(filenamestr, 'w')
42734274
file.write(json.dumps(savdict))
42744275
file.close()
@@ -4665,8 +4666,9 @@ def save_config_gui():
46654666
filename = asksaveasfilename(filetypes=file_type, defaultextension=file_type)
46664667
if not filename:
46674668
return
4668-
filenamestr = str(filename).strip()
4669-
filenamestr = f"{filenamestr}.kcpps" if ".kcpps" not in filenamestr.lower() else filenamestr
4669+
filenamestr = str(filename).strip().lower()
4670+
if not filenamestr.endswith(".kcpps"):
4671+
filenamestr += ".kcpps"
46704672
file = open(filenamestr, 'w')
46714673
file.write(json.dumps(savdict))
46724674
file.close()
@@ -5192,11 +5194,14 @@ def save_config_cli(filename, template):
51925194
if filename is None:
51935195
return
51945196
filenamestr = str(filename).strip()
5195-
filenamestr = f"{filenamestr}.kcpps" if ".kcpps" not in filenamestr.lower() else filenamestr
5197+
if not filenamestr.endswith(".kcpps") and not template:
5198+
filenamestr += ".kcpps"
5199+
if not filenamestr.endswith(".kcppt") and template:
5200+
filenamestr += ".kcppt"
51965201
file = open(filenamestr, 'w')
51975202
file.write(json.dumps(savdict))
51985203
file.close()
5199-
print(f"\nSaved .kcpps configuration file as {filename}\nIt can be loaded with --config [filename] in future.")
5204+
print(f"\nSaved configuration file as {filenamestr}\nIt can be loaded with --config [filename] in future.")
52005205
pass
52015206

52025207
def delete_old_pyinstaller():
@@ -5676,7 +5681,7 @@ def kcpp_main_process(launch_args, g_memory=None, gui_launcher=False):
56765681

56775682
if args.savedatafile and isinstance(args.savedatafile, str):
56785683
filepath = os.path.abspath(args.savedatafile) # Ensure it's an absolute path
5679-
if not filepath.endswith(".jsondb"):
5684+
if not filepath.lower().endswith(".jsondb"):
56805685
filepath += ".jsondb"
56815686
args.savedatafile += ".jsondb"
56825687
try:

0 commit comments

Comments
 (0)