rstudio / pins-r

Pin, discover, and share resources
https://pins.rstudio.com
Other
312 stars 63 forks source link

board_url cache is not cleared by cache_prune, or listed in cache_versions #607

Closed machow closed 1 year ago

machow commented 2 years ago

Unlike other boards, board_url can point directly to to-be-downloaded files. In order to work with cache functions like cache_prune() and pins:::cache_versions(), this board runs this process when downloading a single file:

Because functions like cache_versions look for the structure <cache_root>/<board_hash>/<pin>/<version>/data.txt, this should work okay. The only issue afaict is that the cache is using <pin>/data.txt, rather than <pin>/<version>/data.txt.

Example

github_raw <- "https://raw.githubusercontent.com/"
board <- board_url(c(
    files = paste0(github_raw, "rstudio/pins/master/tests/testthat/pin-files/"),
    rds = paste0(github_raw, "rstudio/pins/master/tests/testthat/pin-rds/"),
    raw = paste0(github_raw, "rstudio/pins/master/tests/testthat/pin-files/first.txt")
))

board %>% pin_download("files")
board %>% pin_download("raw")

# output: [1] "~/Library/Caches/pins/url/87473d3442e598f929b65b6630da6fd8/first.txt"
# note that the cached pin also has data.txt, and download-cache.yaml created in it

# looks for  <pin>/<version>/data.txt file, so doesn't find anything
pins:::cache_versions()
cache_prune(0)                       # no stale pins found
github-actions[bot] commented 1 year ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.