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)
|
name = utils.cleanfilename(name)
|
||||||
if(not fileops.saveexists(name) or (vars.saveow and vars.svowname == name)):
|
if(not fileops.saveexists(name) or (vars.saveow and vars.svowname == name)):
|
||||||
# All clear to save
|
# All clear to save
|
||||||
saveRequest(fileops.storypath(name))
|
e = saveRequest(fileops.storypath(name))
|
||||||
emit('from_server', {'cmd': 'hidesaveas', 'data': ''})
|
|
||||||
vars.saveow = False
|
vars.saveow = False
|
||||||
vars.svowname = ""
|
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:
|
else:
|
||||||
# File exists, prompt for overwrite
|
# File exists, prompt for overwrite
|
||||||
vars.saveow = True
|
vars.saveow = True
|
||||||
@ -1932,11 +1936,16 @@ def saveRequest(savpath):
|
|||||||
})
|
})
|
||||||
|
|
||||||
# Write it
|
# Write it
|
||||||
file = open(savpath, "w")
|
try:
|
||||||
|
file = open(savpath, "w")
|
||||||
|
except Exception as e:
|
||||||
|
return e
|
||||||
try:
|
try:
|
||||||
file.write(json.dumps(js, indent=3))
|
file.write(json.dumps(js, indent=3))
|
||||||
finally:
|
except Exception as e:
|
||||||
file.close()
|
file.close()
|
||||||
|
return e
|
||||||
|
file.close()
|
||||||
|
|
||||||
print("{0}Story saved to {1}!{2}".format(colors.GREEN, path.basename(savpath), colors.END))
|
print("{0}Story saved to {1}!{2}".format(colors.GREEN, path.basename(savpath), colors.END))
|
||||||
|
|
||||||
|
@ -193,6 +193,9 @@
|
|||||||
<div class="aidgpopupcontent">
|
<div class="aidgpopupcontent">
|
||||||
<input class="form-control" type="text" placeholder="Save Name" id="savename">
|
<input class="form-control" type="text" placeholder="Save Name" id="savename">
|
||||||
</div>
|
</div>
|
||||||
|
<div class="popuperror hidden">
|
||||||
|
<span></span>
|
||||||
|
</div>
|
||||||
<div class="saveasoverwrite hidden">
|
<div class="saveasoverwrite hidden">
|
||||||
<span>File already exists. Really overwrite?</span>
|
<span>File already exists. Really overwrite?</span>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user