Fix duplicate get_by_cid method shadowing recipe lookup

Bug: Two get_by_cid methods existed in L1CacheManager. The second
definition shadowed the first, breaking recipe lookup because the
comprehensive method (using find_by_cid) was hidden.

- Remove duplicate get_by_cid method (lines 470-494)
- Add regression test to ensure only one get_by_cid exists
- Add tests for template variables and recipe visibility

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 12:14:59 +00:00
parent 977d9a9258
commit 9f8aa54e2b
3 changed files with 140 additions and 27 deletions

View File

@@ -467,32 +467,6 @@ class L1CacheManager:
return None
def get_by_cid(self, ipfs_cid: str) -> Optional[Path]:
"""Get cached file path by IPFS CID. Fetches from IPFS if not in local cache."""
# Check if we have this CID cached locally (indexed by CID)
cached_path = self.legacy_dir / ipfs_cid
if cached_path.exists() and cached_path.is_file():
return cached_path
# Check cache directory structure
cid_cache_dir = self.cache_dir / ipfs_cid
if cid_cache_dir.exists() and cid_cache_dir.is_dir():
# Look for output file
for f in cid_cache_dir.iterdir():
if f.is_file() and not f.name.endswith('.json'):
return f
# Fetch from IPFS
logger.info(f"Fetching from IPFS: {ipfs_cid[:16]}...")
recovery_path = self.legacy_dir / ipfs_cid
recovery_path.parent.mkdir(parents=True, exist_ok=True)
if ipfs_client.get_file(ipfs_cid, recovery_path):
logger.info(f"Fetched from IPFS: {recovery_path}")
return recovery_path
return None
def has_content(self, cid: str) -> bool:
"""Check if content exists in cache."""
return self.get_by_cid(cid) is not None