mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-06-05 21:59:24 +02:00
WI: Don't explode when user uploads image without a save
This is a band-aid on an underlying problem: there is no save directory to put blobs like images in before the user saves the game. The way forward is probably to have an in-memory (no disk, Colab privacy (thats kind of an oxymoron)) folder or something. I want to expand the data storage functionality into an api in the future so devs can seamlessly do something like: Data.get_file_contents("image/blahblah.png") and they won't have to actually worry about stuff like this
This commit is contained in:
15
aiserver.py
15
aiserver.py
@@ -6715,11 +6715,18 @@ def UI_2_set_wi_image(uid):
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Otherwise assign image
|
try:
|
||||||
with open(path, "wb") as file:
|
# Otherwise assign image
|
||||||
file.write(data)
|
with open(path, "wb") as file:
|
||||||
|
file.write(data)
|
||||||
|
except FileNotFoundError:
|
||||||
|
show_error_notification(
|
||||||
|
"Unable to write image",
|
||||||
|
"Please save the game before uploading images."
|
||||||
|
)
|
||||||
|
return ":(", 500
|
||||||
koboldai_vars.gamesaved = False
|
koboldai_vars.gamesaved = False
|
||||||
return ":)"
|
return ":)", 200
|
||||||
|
|
||||||
@app.route("/get_wi_image/<int(signed=True):uid>", methods=["GET"])
|
@app.route("/get_wi_image/<int(signed=True):uid>", methods=["GET"])
|
||||||
@require_allowed_ip
|
@require_allowed_ip
|
||||||
|
Reference in New Issue
Block a user