Repository navigation
fix: delete leftover files from the cache dir on refresh - #150
Merged
Merged
Conversation
A release that renames or drops a cache file left the old file in ~/.c1i/cache forever. Instead of a cleanup rule per file, list the files the cache is supposed to hold and delete anything else there whenever the OpenAPI cache is rewritten (at most once per 24h). Subdirectories are skipped, and so is a cache dir that is a symlink, whose target may hold files c1i doesn't own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With HOME unset the cache path resolves against the working directory, so the sweep would delete files there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n Windows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Keep both CHANGELOG entries. The sweep test now plants the real pre-rename openapi.yaml as the leftover, since the cache file is api-openapi.yaml. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…siblings Plant a symlink entry, a file inside a subdirectory, and state beside the cache dir. The sweep must remove only the link. Also restore the docs openapi command's output and context after each test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
A release that renames or drops a cache file leaves the old one in
~/.c1i/cache/forever. The rename in #148 (openapi.yaml→api-openapi.yaml) would strand ~0.9 MB per machine. This replaces a cleanup rule per file with one general rule.What
cmd/cache.goholds an allowlist,cacheFiles, of every file the cache dir is meant to contain. Today that is justcacheFileName.pruneCacheDirdeletes every other file in that dir. The write happens at most once per 24h.cmd/agents.mdnow say not to keep your own files in~/.c1i/cache/.What c1i writes, and what this touches
~/.c1i/cache/*~/.c1i.yaml<UserConfigDir>/c1i/credentials/<UserConfigDir>/c1i/tokens/~/.sigstore/root/upgradethrough sigstore-go's default path and shared with other Sigstore tools.c1i-upgrade-*beside the binaryupgradeitselfI chose not to add a
cache clearcommand. Users would have to know to run it, and the automatic sweep already covers leftovers.Known trade-off: two different c1i versions on one machine that use different cache names delete each other's file. The cost is one refetch per refresh and no offline fallback for the other version.
Verification
TestCacheWritePrunesLeftoverFilesdrivesdocs openapiend to end with a stubbed transport.TestCachePruneSkipsSymlinkedCacheDirandTestCachePruneSkipsRelativeCacheDircover the two guards.Lstatis swapped forStat.go build,go vet,go test -count=1 -shuffle=on,golangci-lint,gosec,go mod tidydiff,gitleaks, andgovulncheck(all three GOOS) after merging main with Build with Go 1.27.2 and bump x/net to fix new advisories #149's Go 1.27.2 / x/net bumps.The CHANGELOG entry will conflict trivially with #148.
🤖 Generated with Claude Code