From a4bf0eae247cf8e5da16641d44835681a87f1572 Mon Sep 17 00:00:00 2001 From: gilesb Date: Mon, 12 Jan 2026 21:18:20 +0000 Subject: [PATCH] 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 --- cache_manager.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cache_manager.py b/cache_manager.py index b29900e..d67de47 100644 --- a/cache_manager.py +++ b/cache_manager.py @@ -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}")