Use XDG_CACHE_HOME for the bootstrap cache directory#48
Conversation
Default the disk cache to $XDG_CACHE_HOME/openrdap, falling back to $HOME/.cache/openrdap when XDG_CACHE_HOME is unset or not absolute, instead of $HOME/.openrdap. This keeps non-essential cache files out of $HOME and lets users clear the cache predictably via $XDG_CACHE_HOME. InitDir now uses MkdirAll so the cache parent (e.g. ~/.cache) is created as needed. Closes #35
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughMigrate bootstrap cache from 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
bootstrap/cache/disk_cache.go (1)
49-61: ⚡ Quick winXDG resolution correct. Panic acceptable but could be clearer.
Lines 52-58 correctly ignore relative
XDG_CACHE_HOMEper spec, fall back to$HOME/.cache.Line 55 panic when home dir unknown is harsh but defensible - environment is broken. Consider more specific message like
"HOME environment variable not set or inaccessible"so user knows what's wrong.🔍 Clearer panic message
- panic("Can't determine your home directory") + panic("Cannot determine home directory: HOME environment variable not set or inaccessible")bootstrap/cache/disk_cache_test.go (1)
17-47: 💤 Low valueTest coverage good. Cleanup error acceptable but could be explicit.
Lines 29-46 validate XDG scenarios correctly: absolute path used, unset falls back, relative ignored.
Line 25: Static analysis flagged unchecked
os.RemoveAllerror. In test cleanup, this is standard Go pattern - temp dir cleanup failure won't break test. Acceptable as-is, but can make intent explicit with_ = os.RemoveAll(home).📝 Explicit ignore
- defer os.RemoveAll(home) + defer func() { _ = os.RemoveAll(home) }()
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f2100dac-aab1-4db6-96c8-865e6db6bcc3
📒 Files selected for processing (6)
README.mdbootstrap/cache/disk_cache.gobootstrap/cache/disk_cache_test.gobootstrap/client.gocli.gordap.1
Summary
Implements XDG Base Directory support for the bootstrap disk cache, addressing #35.
The default cache location changes from
$HOME/.openrdapto$XDG_CACHE_HOME/openrdap, falling back to$HOME/.cache/openrdapwhenXDG_CACHE_HOMEis unset or not an absolute path (relative values are ignored per the XDG spec).This keeps non-essential cache files out of
$HOMEand lets users clear the cache predictably via$XDG_CACHE_HOME.Changes
bootstrap/cache/disk_cache.go: resolve the defaultDirfrom$XDG_CACHE_HOME(or$HOME/.cache);InitDirnow usesMkdirAllso the cache parent (e.g.~/.cache) is created as needed.bootstrap/cache/disk_cache_test.go: addTestNewDiskCacheDircovering XDG set / unset / relative.bootstrap/client.gogodoc,cli.go--cache-dirhelp,rdap.1man page,README.md.Notes
The legacy
$HOME/.openrdapdirectory is not migrated or preferred. Since the bootstrap cache is regenerable, existing installs simply re-download the registry files once into the new location. Use--cache-dirto override.Closes #35
Summary by CodeRabbit
Bug Fixes
Documentation
Tests