Repository navigation
Cache downloads in a persistent, release-versioned directory - #62
Open
rafapereirabr wants to merge 2 commits into
Open
rafapereirabr wants to merge 2 commits into
rafapereirabr wants to merge 2 commits into
Conversation
Files were cached in tempdir() and downloaded again in every R session.
They now go to tools::R_user_dir("aopdata", "cache") (or an 'aopdata'
folder inside a directory set with set_aopdata_cache_dir()), in a folder
named after the data release, so a new release never reads old files.
Old releases are deleted once per session (opt-out:
options(aopdata.keep_old_cache = TRUE)).
- New exports: set_aopdata_cache_dir(), get_aopdata_cache_dir(),
list_aopdata_cache(), delete_aopdata_cache(); session-only override
options(aopdata.cache_dir).
- A copy of metadata.csv is kept in the cache and used when it can't be
downloaded, so cached data can be read offline (message class
aopdata_cache).
- delete_aopdata_cache() removes only aopdata's release folders, and the
cache folder only if it is then empty, so user files are never deleted.
- Per-process .part files; a file saved first by another session counts
as downloaded.
- Tests redirect R_user_dir() to tempdir() via setup/teardown files.
Gates: devtools::test (cache|utils) 147 pass; R CMD check --as-cran
0 errors, 0 warnings, 0 notes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Describe the release-versioned cache under tools::R_user_dir(), the data_release constant, test isolation via setup-cache.R, and the maintainer rule that any change to hosted files needs a new data_release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Summary
aopdata used to cache downloads in
tempdir(), so every R session downloaded the same files again. Files now go to a persistent cache that lives across sessions, versioned by data release.tools::R_user_dir("aopdata", "cache")by default, in a folder named after the data release (aopdata_data_release_v1.0.0). A new data release never reads files cached from an old one.options(aopdata.keep_old_cache = TRUE)opts out.set_aopdata_cache_dir(path): creates anaopdatafolder insidepathand saves the setting across sessions;path = NULLresets to the default.get_aopdata_cache_dir()list_aopdata_cache()delete_aopdata_cache()options(aopdata.cache_dir = <path>), e.g.tempdir().metadata.csvis kept in the cache and used for the rest of the session when it can't be downloaded, so cached data can be read offline. The message has classaopdata_cache.data_releaseinR/aopdata.R. It names the cache folder and builds both GitHub mirror URLs.Things a reviewer should know
delete_aopdata_cache()never deletes user files. It removes aopdata's release folders, then the cache folder only if nothing else is left in it. Review found that a pre-existing user folder or file namedaopdatainside the chosen path would otherwise be wiped.data_release. Any change to the hosted files requires bumpingdata_releaseand the GitHub release tag. This rule is added to.claude/rules/r-package-conventions.md..partfile. If another session saved the same file first (on Windows the rename fails while that file is open), the file counts as downloaded.read_*()signatures are unchanged and nocacheargument was added.get_,list_) only read. Theset_anddelete_examples are guarded byinteractive()and leave the user's settings as they were.setup-cache.Randteardown-cache.Rredirecttools::R_user_dir()totempdir()for the whole suite, so tests never touch the real cache or config.devtools::check()builds vignettes with NOT_CRAN set, so those do write to the developer's real cache. That's expected.aopdata (development version)heading.Checks
devtools::test(): 258 passed, 0 failed (including the network tests)R CMD check --as-cran: 0 errors, 0 warnings, 0 notesr-package-reviewer): one MAJOR finding fixed in round 1; dry in round 2aopdata_cachemessage, 0 failures), an uncreatable cache dir, and the rename raceNEWS.md: updated; both READMEs have a new "Cache" section🤖 Generated with Claude Code