Include koboldai_vars.save_story().

This commit is contained in:
jojorne
2023-02-22 15:42:56 -03:00
parent d6c9f5f1f5
commit d3bedfcbda
2 changed files with 4 additions and 4 deletions

View File

@@ -7273,7 +7273,7 @@ def save():
save_name = koboldai_vars.story_name if koboldai_vars.story_name != "" else "untitled"
same_story = True
if os.path.exists("stories/{}".format(save_name)):
with open("stories/{}/story.json".format(save_name), "r") as settings_file:
with open("stories/{}/story.json".format(save_name), "r", encoding="utf-8") as settings_file:
json_data = json.load(settings_file)
if 'story_id' in json_data:
same_story = json_data['story_id'] == koboldai_vars.story_id

View File

@@ -938,7 +938,7 @@ class story_settings(settings):
while os.path.exists(self.save_paths.base):
try:
# If the stories share a story id, overwrite the existing one.
with open(self.save_paths.story, "r") as file:
with open(self.save_paths.story, "r", encoding="utf-8") as file:
j = json.load(file)
if self.story_id == j["story_id"]:
break
@@ -960,7 +960,7 @@ class story_settings(settings):
v2_path = os.path.join("stories", f"{self.story_name}_v2.json")
if os.path.exists(v2_path):
logger.info("Migrating v2 save")
with open(v2_path, "r") as file:
with open(v2_path, "r", encoding="utf-8") as file:
v2j = json.load(file)
if v2j["story_id"] == self.story_id:
@@ -968,7 +968,7 @@ class story_settings(settings):
else:
logger.warning(f"Story mismatch in v2 migration. Existing file had story id {v2j['story_id']} but we have {self.story_id}")
with open(self.save_paths.story, "w") as file:
with open(self.save_paths.story, "w", encoding="utf-8") as file:
file.write(self.to_json())
self.gamesaved = True