Skip to content

Move registry cache to XDG cache directory - #34

Merged
fuzzyporpoise merged 2 commits into
mainfrom
move-cache
Sep 30, 2026
Merged

fuzzyporpoise merged 2 commits into
mainfrom
move-cache

Conversation

@fuzzyporpoise

Copy link
Copy Markdown
Owner

Summary

Adds a machine-local project registry at $XDG_CACHE_HOME/lnk/registry.json, moving it out of the lnk repo so relocating or renaming the repo no longer orphans the mapping. Complements the existing project-scope work.

What's new

  • XDG registry - the project cache moves from <repo>/.lnkprojectcache to $XDG_CACHE_HOME/lnk/registry.json, falling back to ~/.cache/lnk/registry.json and then the OS temp directory.
  • LNK_REGISTRY override - redirect the registry file anywhere, matching the TODO_REGISTRY escape hatch in the todo CLI.
  • Atomic saves - RegistryPath() resolves the location, the cache directory is created on demand, and writes go through a temp file plus rename.
  • Docs and help text - project cache, project sync --all, and the doctor messages now describe the registry; README and AGENTS.md are updated.

Behavior changes / guardrails

  • No automatic migration: an existing <repo>/.lnkprojectcache is ignored; run lnk project cache --scan <dir> to rebuild the registry.
  • The registry is never written into the lnk repo, so it cannot be committed or synced across machines.
  • The on-disk schema is unchanged ({"projects":[...]}), so consumers only need the new path.

Testing

  • Unit tests cover RegistryPath() (override, XDG, home fallback) and that saves create the registry directory and leave no temp file behind.
  • Project cache, sync --all, and doctor tests resolve the registry through service.RegistryPath(), and TestHome pins XDG_CACHE_HOME for hermetic runs.
  • make check runs fmt, vet, lint, unit, and integration suites; all green.

@fuzzyporpoise fuzzyporpoise self-assigned this Sep 30, 2026
@fuzzyporpoise
fuzzyporpoise merged commit 65c6a3a into main Sep 30, 2026
4 checks passed
@fuzzyporpoise
fuzzyporpoise deleted the move-cache branch September 30, 2026 21:13
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.

1 participant