Fix cache listing to include files from new structure
- Update list_all() to scan cache_dir for legacy files directly
(old files stored as CACHE_DIR/{hash}, not CACHE_DIR/legacy/)
- Update cache listing endpoints to use cache_manager.list_all()
instead of iterating CACHE_DIR.iterdir() directly
- This ensures uploaded files appear in the cache UI regardless
of whether they're in the old or new cache structure
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -278,20 +278,39 @@ class L1CacheManager:
|
||||
def list_all(self) -> List[CachedFile]:
|
||||
"""List all cached files."""
|
||||
files = []
|
||||
seen_hashes = set()
|
||||
|
||||
# New cache structure entries
|
||||
for entry in self.cache.list_entries():
|
||||
files.append(CachedFile.from_cache_entry(entry))
|
||||
if entry.content_hash:
|
||||
seen_hashes.add(entry.content_hash)
|
||||
|
||||
# Include legacy files
|
||||
for f in self.legacy_dir.iterdir():
|
||||
if f.is_file():
|
||||
files.append(CachedFile(
|
||||
node_id=f.name,
|
||||
content_hash=f.name,
|
||||
path=f,
|
||||
size_bytes=f.stat().st_size,
|
||||
node_type="legacy",
|
||||
created_at=f.stat().st_mtime,
|
||||
))
|
||||
# Legacy files stored directly in cache_dir (old structure)
|
||||
# These are files named by content_hash directly in CACHE_DIR
|
||||
for f in self.cache_dir.iterdir():
|
||||
# Skip directories and special files
|
||||
if not f.is_file():
|
||||
continue
|
||||
# Skip metadata/auxiliary files
|
||||
if f.suffix in ('.json', '.mp4'):
|
||||
continue
|
||||
# Skip if name doesn't look like a hash (64 hex chars)
|
||||
if len(f.name) != 64 or not all(c in '0123456789abcdef' for c in f.name):
|
||||
continue
|
||||
# Skip if already seen via new cache
|
||||
if f.name in seen_hashes:
|
||||
continue
|
||||
|
||||
files.append(CachedFile(
|
||||
node_id=f.name,
|
||||
content_hash=f.name,
|
||||
path=f,
|
||||
size_bytes=f.stat().st_size,
|
||||
node_type="legacy",
|
||||
created_at=f.stat().st_mtime,
|
||||
))
|
||||
seen_hashes.add(f.name)
|
||||
|
||||
return files
|
||||
|
||||
|
||||
Reference in New Issue
Block a user