Add debug logging to resolve_asset

This commit is contained in:
giles
2026-02-03 00:00:30 +00:00
parent 3d5a08a7dc
commit 89b2fd3d2e

View File

@@ -43,15 +43,19 @@ def resolve_asset(ref: str, actor_id: Optional[str] = None) -> Optional[Path]:
Path to the asset file, or None if not found Path to the asset file, or None if not found
""" """
global _resolve_loop, _db_initialized global _resolve_loop, _db_initialized
import sys
print(f"RESOLVE_ASSET: ref={ref}, actor_id={actor_id}", file=sys.stderr)
cache_mgr = get_cache_manager() cache_mgr = get_cache_manager()
# Try as direct CID first # Try as direct CID first
path = cache_mgr.get_by_cid(ref) path = cache_mgr.get_by_cid(ref)
print(f"RESOLVE_ASSET: get_by_cid({ref}) = {path}", file=sys.stderr)
if path and path.exists(): if path and path.exists():
logger.info(f"Resolved {ref[:16]}... as CID to {path}") logger.info(f"Resolved {ref[:16]}... as CID to {path}")
return path return path
# Try as friendly name if actor_id provided # Try as friendly name if actor_id provided
print(f"RESOLVE_ASSET: trying friendly name lookup, actor_id={actor_id}", file=sys.stderr)
if actor_id: if actor_id:
import asyncio import asyncio
import database import database
@@ -70,13 +74,17 @@ def resolve_asset(ref: str, actor_id: Optional[str] = None) -> Optional[Path]:
_db_initialized = True _db_initialized = True
cid = _resolve_loop.run_until_complete(resolve_friendly_name(actor_id, ref)) cid = _resolve_loop.run_until_complete(resolve_friendly_name(actor_id, ref))
print(f"RESOLVE_ASSET: resolve_friendly_name({actor_id}, {ref}) = {cid}", file=sys.stderr)
if cid: if cid:
path = cache_mgr.get_by_cid(cid) path = cache_mgr.get_by_cid(cid)
print(f"RESOLVE_ASSET: get_by_cid({cid}) = {path}", file=sys.stderr)
if path and path.exists(): if path and path.exists():
print(f"RESOLVE_ASSET: SUCCESS - resolved to {path}", file=sys.stderr)
logger.info(f"Resolved '{ref}' via friendly name to {path}") logger.info(f"Resolved '{ref}' via friendly name to {path}")
return path return path
except Exception as e: except Exception as e:
print(f"RESOLVE_ASSET: ERROR - {e}", file=sys.stderr)
logger.warning(f"Failed to resolve friendly name '{ref}': {e}") logger.warning(f"Failed to resolve friendly name '{ref}': {e}")
logger.warning(f"Could not resolve asset reference: {ref}") logger.warning(f"Could not resolve asset reference: {ref}")