feat(hosted-file): add archive_content to intelligent download ID resolution
This commit is contained in:
@@ -210,15 +210,23 @@ async def download_file_action(
|
||||
|
||||
# 2. Resolve File Record
|
||||
# ID Vision: Attempt to resolve the ID.
|
||||
# If not found in hosted_file, check if it's an event_file ID that we can resolve to a hosted_file.
|
||||
# If not found in hosted_file, check if it's an event_file or archive_content ID that we can resolve.
|
||||
resolved_id = redis_lookup_id_random(record_id_random=hosted_file_id, table_name='hosted_file')
|
||||
|
||||
if not resolved_id:
|
||||
log.info(f"ID {hosted_file_id} not found in hosted_file. Checking event_file...")
|
||||
log.info(f"ID {hosted_file_id} not found in hosted_file. Checking container tables...")
|
||||
# A. Check event_file
|
||||
if ef_id := redis_lookup_id_random(record_id_random=hosted_file_id, table_name='event_file'):
|
||||
if ef_rec := sql_select(sql="SELECT hosted_file_id FROM event_file WHERE id = :id", data={'id': ef_id}):
|
||||
resolved_id = ef_rec.get('hosted_file_id')
|
||||
log.info(f"Resolved event_file {hosted_file_id} to hosted_file {resolved_id}")
|
||||
|
||||
# B. Check archive_content
|
||||
if not resolved_id:
|
||||
if ac_id := redis_lookup_id_random(record_id_random=hosted_file_id, table_name='archive_content'):
|
||||
if ac_rec := sql_select(sql="SELECT hosted_file_id FROM archive_content WHERE id = :id", data={'id': ac_id}):
|
||||
resolved_id = ac_rec.get('hosted_file_id')
|
||||
log.info(f"Resolved archive_content {hosted_file_id} to hosted_file {resolved_id}")
|
||||
|
||||
if not resolved_id:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Hosted file record not found.")
|
||||
|
||||
Reference in New Issue
Block a user