Fix cache_folder bug introduced in 37eff915d6

This commit is contained in:
oobabooga 2024-01-04 07:49:40 -08:00
parent 37eff915d6
commit e4d724eb3f

View File

@ -567,10 +567,10 @@ def generate_pfp_cache(character):
for path in [Path(f"characters/{character}.{extension}") for extension in ['png', 'jpg', 'jpeg']]: for path in [Path(f"characters/{character}.{extension}") for extension in ['png', 'jpg', 'jpeg']]:
if path.exists(): if path.exists():
original_img = Image.open(path) original_img = Image.open(path)
original_img.save(Path('{cache_folder}/pfp_character.png'), format='PNG') original_img.save(Path(f'{cache_folder}/pfp_character.png'), format='PNG')
thumb = make_thumbnail(original_img) thumb = make_thumbnail(original_img)
thumb.save(Path('{cache_folder}/pfp_character_thumb.png'), format='PNG') thumb.save(Path(f'{cache_folder}/pfp_character_thumb.png'), format='PNG')
return thumb return thumb
@ -596,7 +596,7 @@ def load_character(character, name1, name2):
data = json.loads(file_contents) if extension == "json" else yaml.safe_load(file_contents) data = json.loads(file_contents) if extension == "json" else yaml.safe_load(file_contents)
cache_folder = Path(shared.args.disk_cache_dir) cache_folder = Path(shared.args.disk_cache_dir)
for path in [Path("{cache_folder}/pfp_character.png"), Path("{cache_folder}/pfp_character_thumb.png")]: for path in [Path(f"{cache_folder}/pfp_character.png"), Path(f"{cache_folder}/pfp_character_thumb.png")]:
if path.exists(): if path.exists():
path.unlink() path.unlink()
@ -719,12 +719,12 @@ def upload_your_profile_picture(img):
cache_folder.mkdir() cache_folder.mkdir()
if img is None: if img is None:
if Path("{cache_folder}/pfp_me.png").exists(): if Path(f"{cache_folder}/pfp_me.png").exists():
Path("{cache_folder}/pfp_me.png").unlink() Path(f"{cache_folder}/pfp_me.png").unlink()
else: else:
img = make_thumbnail(img) img = make_thumbnail(img)
img.save(Path('{cache_folder}/pfp_me.png')) img.save(Path(f'{cache_folder}/pfp_me.png'))
logger.info('Profile picture saved to "{cache_folder}/pfp_me.png"') logger.info(f'Profile picture saved to "{cache_folder}/pfp_me.png"')
def generate_character_yaml(name, greeting, context): def generate_character_yaml(name, greeting, context):