From 07ed50160be7d35abd04d7cf79ce35634781a545 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Thu, 22 Jun 2023 11:13:56 -0600 Subject: [PATCH 1/2] Require purrr 1.0.0, for `otherwise` default --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index c79091a0..a0023fb0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,7 +31,7 @@ Imports: jsonlite, lifecycle, magrittr, - purrr, + purrr (>= 1.0.0), rappdirs, rlang (>= 1.1.0), tibble, From ff30f5955830768b9bc7843aba50d13167141b21 Mon Sep 17 00:00:00 2001 From: Julia Silge Date: Thu, 22 Jun 2023 17:23:12 -0600 Subject: [PATCH 2/2] Fix uses of `possibly()` (#754) * Fix implementation of `possibly_pin_meta` * Fix implementation of `possibly_drive_ls()` * Update R/board_gdrive.R Co-authored-by: Hadley Wickham * Use `tryCatch()` --------- Co-authored-by: Hadley Wickham --- R/board_gdrive.R | 5 ++++- R/pin-meta.R | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/R/board_gdrive.R b/R/board_gdrive.R index 47af5b77..a613bdb7 100644 --- a/R/board_gdrive.R +++ b/R/board_gdrive.R @@ -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 } diff --git a/R/pin-meta.R b/R/pin-meta.R index d5fb4635..2c4e7d2f 100644 --- a/R/pin-meta.R +++ b/R/pin-meta.R @@ -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)