Skip to content

parity(#243): add csp clear orphans to remove cached indexes whose source path no longer exists #87

Description

@amondnet

Summary

Upstream semble #243 (ca197f7) added semble clear orphans: removes cached indexes whose local source directory no longer exists. csp's clear only accepts all | index | savings.

Upstream

  • cli.py::_clear_orphans(cache_folder): for each */index* entry, read metadata.json, take root_path; skip unless it is a non-empty string and cache_key(root_path) equals the entry's directory name (this excludes git-URL entries, whose root_path is a temp clone dir); delete when Path(root_path) does not exist.
  • cache.py::cache_key(path) extracted so the CLI can verify the key.
  • clear all does not include orphans; orphans is its own choice.

csp status

  • crates/csp/src/bin/csp/main.rs::run_clear_at: choices ["all","index","savings"]. Not reflected.
  • IndexManifest.source_id: Option<String> (indexing/index.rs) records the normalized source, and indexing/cache.rs::resolve_cache_dir derives the key from sourceId + content + ref — so an orphan check can recompute the key from the manifest and compare it to the directory name, as upstream does.

Tasks

  • Add orphans to clear choices + CLEAR_CHOICES help text.
  • clear_orphan_indexes(loc) in indexing/cache.rs: iterate <home>/index/*/manifest.json, skip git sources / key mismatches / unparsable manifests, remove entries whose source_id path no longer exists; keep the existing "only under the real index root" safety check.
  • README.md + README.ko.md csp clear section.
  • Tests against a temp cache dir (orphan removed, live entry kept, git entry kept, malformed manifest skipped).

Refs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions