Skip to content

Commit

Permalink
Fix uses of possibly() (#754)
Browse files Browse the repository at this point in the history
* Fix implementation of `possibly_pin_meta`

* Fix implementation of `possibly_drive_ls()`

* Update R/board_gdrive.R

Co-authored-by: Hadley Wickham <[email protected]>

* Use `tryCatch()`

---------

Co-authored-by: Hadley Wickham <[email protected]>
  • Loading branch information
juliasilge and hadley authored Jun 22, 2023
1 parent 07ed501 commit ff30f59
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion R/board_gdrive.R
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,13 @@ required_pkgs.pins_board_gdrive <- function(x, ...) {

# Helpers -----------------------------------------------------------------

possibly_drive_ls <- function(...) {
tryCatch(googledrive::drive_ls(...), error = function(err) NULL)
}

gdrive_file_exists <- function(board, name) {
path <- fs::path(board$dribble$name, fs::path_dir(name))
name <- fs::path_file(name)
possibly_drive_ls <- purrr::possibly(googledrive::drive_ls)
all_names <- possibly_drive_ls(path)
name %in% all_names$name
}
Expand Down
4 changes: 3 additions & 1 deletion R/pin-meta.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ pin_meta <- function(board, name, version = NULL, ...) {
UseMethod("pin_meta")
}

possibly_pin_meta <- possibly(pin_meta)
possibly_pin_meta <- function(...) {
tryCatch(pin_meta(...), error = function(err) NULL)
}

multi_meta <- function(board, names) {
meta <- map(names, possibly(pin_meta, empty_local_meta), board = board)
Expand Down

0 comments on commit ff30f59

Please sign in to comment.