From e29ff23f32bcb07e324bfbff6c7c0892f37f044a Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 3 Feb 2026 17:53:27 -0500 Subject: [PATCH] fix(api-v3): ensure subdirectory_path persistence and reload in file actions --- app/routers/api_v3_actions_hosted_file.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/routers/api_v3_actions_hosted_file.py b/app/routers/api_v3_actions_hosted_file.py index cf2ca35..dc8126d 100644 --- a/app/routers/api_v3_actions_hosted_file.py +++ b/app/routers/api_v3_actions_hosted_file.py @@ -131,13 +131,15 @@ async def upload_files_action( # Use existing record hosted_file_id_int = existing_rec.get('id') - # Migration check: Update subdirectory if missing - if not existing_rec.get('subdirectory_path') and file_info.get('subdirectory_path'): + # Migration check: Update subdirectory if missing or mismatched + 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( table_name = 'hosted_file', 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) else: # Create new record