Skip to content

fix: filter stale cache entries in capture_initial_cached_targets and clean orphans on every build#9

Merged
metasmile merged 1 commit into
mainfrom
8-cache-sidebar-stale-entries
May 31, 2026
Merged

fix: filter stale cache entries in capture_initial_cached_targets and clean orphans on every build#9
metasmile merged 1 commit into
mainfrom
8-cache-sidebar-stale-entries

Conversation

@metasmile

Copy link
Copy Markdown
Contributor

Closes #8

Problem

should_rerender_for_sidebar compares build_targets against a snapshot of _cached/ directories. When stale cache entries from deleted sources remain in _cached/, every HTML target re-renders on every build.

Changes

src/sdb/build.py

  1. capture_initial_cached_targets: intersect with TARGET_CONFIG.keys() so stale entries are excluded from the comparison set.
  2. build_targets: call _cleanup_orphaned_caches(set(TARGET_CONFIG.keys()), docs_root) immediately after capture_initial_cached_targets, ensuring stale cache directories are physically removed every build cycle regardless of execution mode.

tests/test_cache_lifecycle.py (new, 14 tests)

  • capture_initial_cached_targets correctly filters stale entries
  • should_rerender_for_sidebar correctly detects added/removed targets
  • _cleanup_orphaned_caches correctly removes orphaned directories

@metasmile metasmile merged commit 220d9cc into main May 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

should_rerender_for_sidebar fails for all targets when stale cache entries exist in _cached/

1 participant