refactor: Migrate file-based data storage to database
This commit is contained in:
@@ -157,10 +157,12 @@ def update_persona_sample(bp, folder):
|
||||
|
||||
author_name = meta.get('author', 'Unknown Author')
|
||||
|
||||
# Use a local file mirror for the engine context (runs outside Flask app context)
|
||||
_personas_file = os.path.join(config.PERSONAS_DIR, "personas.json")
|
||||
personas = {}
|
||||
if os.path.exists(config.PERSONAS_FILE):
|
||||
if os.path.exists(_personas_file):
|
||||
try:
|
||||
with open(config.PERSONAS_FILE, 'r') as f: personas = json.load(f)
|
||||
with open(_personas_file, 'r') as f: personas = json.load(f)
|
||||
except: pass
|
||||
|
||||
if author_name not in personas:
|
||||
@@ -189,4 +191,4 @@ def update_persona_sample(bp, folder):
|
||||
if filename not in personas[author_name]['sample_files']:
|
||||
personas[author_name]['sample_files'].append(filename)
|
||||
|
||||
with open(config.PERSONAS_FILE, 'w') as f: json.dump(personas, f, indent=2)
|
||||
with open(_personas_file, 'w') as f: json.dump(personas, f, indent=2)
|
||||
|
||||
Reference in New Issue
Block a user