fix(api-v3): ensure subdirectory_path persistence and reload in file actions

This commit is contained in:
Scott Idem
2026-02-03 17:53:27 -05:00
parent 69622dbea6
commit e29ff23f32

View File

@@ -131,13 +131,15 @@ async def upload_files_action(
# Use existing record # Use existing record
hosted_file_id_int = existing_rec.get('id') hosted_file_id_int = existing_rec.get('id')
# Migration check: Update subdirectory if missing # Migration check: Update subdirectory if missing or mismatched
if not existing_rec.get('subdirectory_path') and file_info.get('subdirectory_path'): if file_info.get('subdirectory_path') and existing_rec.get('subdirectory_path') != file_info['subdirectory_path']:
log.info(f"Updating subdirectory_path for existing record {hosted_file_id_int} to {file_info['subdirectory_path']}")
sql_update( sql_update(
table_name = 'hosted_file', table_name = 'hosted_file',
data = {'id': hosted_file_id_int, 'subdirectory_path': file_info['subdirectory_path']} data = {'id': hosted_file_id_int, 'subdirectory_path': file_info['subdirectory_path']}
) )
# Reload to get the latest DB state (including updated path)
hosted_file_dict = load_hosted_file_obj(hosted_file_id=hosted_file_id_int, model_as_dict=True) hosted_file_dict = load_hosted_file_obj(hosted_file_id=hosted_file_id_int, model_as_dict=True)
else: else:
# Create new record # Create new record