mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-01-23 13:50:25 +01:00
Catch and display errors from "Save As"
This commit is contained in:
parent
e31640a89d
commit
16184ceee8
17
aiserver.py
17
aiserver.py
@ -1831,10 +1831,14 @@ def saveas(name):
|
||||
name = utils.cleanfilename(name)
|
||||
if(not fileops.saveexists(name) or (vars.saveow and vars.svowname == name)):
|
||||
# All clear to save
|
||||
saveRequest(fileops.storypath(name))
|
||||
emit('from_server', {'cmd': 'hidesaveas', 'data': ''})
|
||||
e = saveRequest(fileops.storypath(name))
|
||||
vars.saveow = False
|
||||
vars.svowname = ""
|
||||
if(e is None):
|
||||
emit('from_server', {'cmd': 'hidesaveas', 'data': ''})
|
||||
else:
|
||||
print("{0}{1}{2}".format(colors.RED, str(e), colors.END))
|
||||
emit('from_server', {'cmd': 'popuperror', 'data': str(e)})
|
||||
else:
|
||||
# File exists, prompt for overwrite
|
||||
vars.saveow = True
|
||||
@ -1932,11 +1936,16 @@ def saveRequest(savpath):
|
||||
})
|
||||
|
||||
# Write it
|
||||
file = open(savpath, "w")
|
||||
try:
|
||||
file = open(savpath, "w")
|
||||
except Exception as e:
|
||||
return e
|
||||
try:
|
||||
file.write(json.dumps(js, indent=3))
|
||||
finally:
|
||||
except Exception as e:
|
||||
file.close()
|
||||
return e
|
||||
file.close()
|
||||
|
||||
print("{0}Story saved to {1}!{2}".format(colors.GREEN, path.basename(savpath), colors.END))
|
||||
|
||||
|
@ -193,6 +193,9 @@
|
||||
<div class="aidgpopupcontent">
|
||||
<input class="form-control" type="text" placeholder="Save Name" id="savename">
|
||||
</div>
|
||||
<div class="popuperror hidden">
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="saveasoverwrite hidden">
|
||||
<span>File already exists. Really overwrite?</span>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user