Add filesystem fallback when artdag Cache lookup fails
The artdag Cache object doesn't persist state across process restarts,
so cache.get(node_id) returns None even when files exist on disk.
Now we check the filesystem directly at {cache_dir}/nodes/{node_id}/output.*
when the in-memory cache lookup fails but we have a valid node_id from
the Redis index.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -457,6 +457,15 @@ class L1CacheManager:
|
||||
logger.info(f"get_by_cid: Found via index: {path}")
|
||||
return path
|
||||
|
||||
# artdag Cache doesn't know about entry - check filesystem directly
|
||||
# Files are stored at {cache_dir}/nodes/{node_id}/output.*
|
||||
nodes_dir = self.cache_dir / "nodes" / node_id
|
||||
if nodes_dir.exists():
|
||||
for f in nodes_dir.iterdir():
|
||||
if f.name.startswith("output."):
|
||||
logger.info(f"get_by_cid: Found on filesystem: {f}")
|
||||
return f
|
||||
|
||||
# For uploads, node_id == cid, so try direct lookup
|
||||
# This works even if cache index hasn't been reloaded
|
||||
path = self.cache.get(cid)
|
||||
@@ -465,6 +474,15 @@ class L1CacheManager:
|
||||
self._set_content_index(cid, cid)
|
||||
return path
|
||||
|
||||
# Check filesystem directly for cid as node_id
|
||||
nodes_dir = self.cache_dir / "nodes" / cid
|
||||
if nodes_dir.exists():
|
||||
for f in nodes_dir.iterdir():
|
||||
if f.name.startswith("output."):
|
||||
logger.info(f"get_by_cid: Found on filesystem (direct): {f}")
|
||||
self._set_content_index(cid, cid)
|
||||
return f
|
||||
|
||||
# Scan cache entries (fallback for new structure)
|
||||
entry = self.cache.find_by_cid(cid)
|
||||
logger.info(f"get_by_cid: find_by_cid({cid[:16]}...) returned entry={entry}")
|
||||
|
||||
Reference in New Issue
Block a user