Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cache_prune() and friends for board_url() #734

Merged
merged 2 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* Added new `headers` argument for `board_url()`, mostly for authentication, as
well as new board for Connect vanity URLs `board_connect_url()` (#732).

* Fixed bug in `cache_prune()` to correctly find caches for `board_url()` (#734).

# pins 1.1.0

## Breaking changes
Expand Down
4 changes: 1 addition & 3 deletions R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ cache_boards <- function() {
}

cache_versions <- function() {
pins <- fs::dir_ls(cache_boards(), type = "directory")
versions <- fs::dir_ls(pins, type = "directory")

versions <- fs::dir_ls(cache_boards(), recurse = 2, type = "directory")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why this behaves differently? I wouldn't have expected this code to give a different result, so something about my understanding of dir_ls() is flawed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's that recurse = 2 goes down 2 levels and the old code just went down one:

fs::dir_ls(type = "directory")
#> R         blog      inst      man       revdep    tests     tools     vignettes
fs::dir_ls(type = "directory", recurse = 1)
#> R                  blog               blog/pins-0-2-0    blog/pins-0-3-0    
#> blog/pins-0-4-0    inst               inst/preview       inst/secret        
#> man                man/figures        revdep             tests              
#> tests/testthat     tools              vignettes          vignettes/articles
fs::dir_ls(type = "directory", recurse = 2)
#> R                                blog                             
#> blog/pins-0-2-0                  blog/pins-0-2-0/images           
#> blog/pins-0-3-0                  blog/pins-0-3-0/images           
#> blog/pins-0-4-0                  blog/pins-0-4-0/images           
#> inst                             inst/preview                     
#> inst/preview/highlight.js-9.15.9 inst/preview/pagedtable-1.1      
#> inst/secret                      man                              
#> man/figures                      revdep                           
#> tests                            tests/testthat                   
#> tests/testthat/_snaps            tests/testthat/datatxt           
#> tests/testthat/files             tests/testthat/pin-board         
#> tests/testthat/pin-files         tests/testthat/pin-rds           
#> tools                            vignettes                        
#> vignettes/articles

Created on 2023-04-19 with reprex v2.0.2

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oooh, duh.

versions[fs::file_exists(fs::path(versions, "data.txt"))]
}

Expand Down