MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / dir_is_cache_tree

Function dir_is_cache_tree

src/discover/discover.c:587–601  ·  view source on GitHub ↗

The cache directory holds every indexed project's graph database. When a custom * CBM_CACHE_DIR sits inside a repository — which happens in tests and is legal in * production — walking into it would pull other projects' databases into this * project's file list. Prune it by absolute path. * * This is the narrow remedy for a concern that was briefly implemented as * refusing any root containi

Source from the content-addressed store, hash-verified

585 * refusing any root containing the cache: refusing a whole root was too blunt,
586 * and not walking the cache is what the concern actually asks for. */
587static bool dir_is_cache_tree(const char *abs_path) {
588 const char *cache = g_walk_cache_dir;
589 if (!cache[0] || !abs_path || !abs_path[0]) {
590 return false;
591 }
592 size_t n = strlen(cache);
593 while (n > 1 && (cache[n - 1] == '/' || cache[n - 1] == '\\')) {
594 n--;
595 }
596 if (strncmp(abs_path, cache, n) != 0) {
597 return false;
598 }
599 /* Boundary-aware so "<cache>x" is not treated as living under "<cache>". */
600 return abs_path[n] == '\0' || abs_path[n] == '/' || abs_path[n] == '\\';
601}
602
603static bool should_skip_directory(const char *entry_name, const char *rel_path,
604 const cbm_discover_opts_t *opts, const cbm_gitignore_t *gitignore,

Callers 1

walk_dir_process_entryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected