- Refactored filesystem scan cache integration to use pre-scanned entries from fs_cache module instead of manual directory walking in grep.rs. - Extracted filesystem scan cache invalidation helpers into dedicated fs-cache-invalidation.ts module with three functions: invalidateFsScanAfterWrite, invalidateFsScanAfterDelete, and invalidateFsScanAfterRename. - Centralized file mention discovery profile configuration into getMentionCandidateDiscoveryProfile() function for improved maintainability. - Added comprehensive documentation of filesystem-scan cache architecture contract including cache key specifications, TTL policies, and invalidation patterns. - Updated CHANGELOG.md to document filesystem scan cache invalidation helpers and named discovery profile for file mention candidates.
29 lines
797 B
TypeScript
29 lines
797 B
TypeScript
import { invalidateFsScanCache } from "@oh-my-pi/pi-natives";
|
|
|
|
/**
|
|
* Invalidate shared filesystem scan caches after a content write/update.
|
|
*/
|
|
export function invalidateFsScanAfterWrite(path: string): void {
|
|
invalidateFsScanCache(path);
|
|
}
|
|
|
|
/**
|
|
* Invalidate shared filesystem scan caches after deleting a file.
|
|
*/
|
|
export function invalidateFsScanAfterDelete(path: string): void {
|
|
invalidateFsScanCache(path);
|
|
}
|
|
|
|
/**
|
|
* Invalidate shared filesystem scan caches after a rename/move.
|
|
*
|
|
* Both source and destination paths must be invalidated because cached roots can
|
|
* include either side of the move.
|
|
*/
|
|
export function invalidateFsScanAfterRename(oldPath: string, newPath: string): void {
|
|
invalidateFsScanCache(oldPath);
|
|
if (newPath !== oldPath) {
|
|
invalidateFsScanCache(newPath);
|
|
}
|
|
}
|