Skip to content

Fix cache path inconsistency when running from non-project directory#6

Merged
jongalloway merged 2 commits intofeat/spectre-cli-ui-upgradesfrom
copilot/sub-pr-5
Feb 26, 2026
Merged

Fix cache path inconsistency when running from non-project directory#6
jongalloway merged 2 commits intofeat/spectre-cli-ui-upgradesfrom
copilot/sub-pr-5

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

CacheService defaulted its cache directory to Directory.GetCurrentDirectory()/.cache, while --clear-cache resolved the path via repoRoot. Running from the repo root (e.g., dotnet run --project src/NewsletterGenerator) caused cache clears and cache reads/writes to target different directories.

Changes

  • RunGenerateAsync: Compute cacheDir from repoRoot once, reuse it for both the clear-cache logic and the CacheService constructor — replacing the implicit cwd-based default.
// Before: cacheDir scoped inside clearCache block; CacheService used cwd implicitly
var cache = new CacheService(loggerFactory.CreateLogger<CacheService>(), forceRefresh: forceRefresh);

// After: single canonical path passed to both
var cacheDir = Path.Combine(repoRoot, "src", "NewsletterGenerator", ".cache");
// ...clearCache logic uses cacheDir...
var cache = new CacheService(loggerFactory.CreateLogger<CacheService>(), cacheDir, forceRefresh: forceRefresh);

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: jongalloway <68539+jongalloway@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Spectre CLI command UX and dashboard improvements Fix cache path inconsistency when running from non-project directory Feb 26, 2026
@jongalloway jongalloway marked this pull request as ready for review February 26, 2026 21:40
@jongalloway jongalloway merged commit acf37ff into feat/spectre-cli-ui-upgrades Feb 26, 2026
1 check failed
@jongalloway jongalloway deleted the copilot/sub-pr-5 branch February 27, 2026 17:57
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.

2 participants