From e4c7b7efbf13fc23bcaaf5727a3dee2fcf2dcab6 Mon Sep 17 00:00:00 2001 From: muschellij2 Date: Thu, 21 Jan 2021 13:25:09 -0500 Subject: [PATCH] moved stop aroudn to fail quicker --- R/remote_package_dcf.R | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/R/remote_package_dcf.R b/R/remote_package_dcf.R index 4b248f5..5764cc2 100644 --- a/R/remote_package_dcf.R +++ b/R/remote_package_dcf.R @@ -35,6 +35,11 @@ get_remote_package_dcf = function( tmp <- tempfile() api_call = grepl("api", tolower(url)) + if (api_call) { + if (!requireNamespace("base64enc", quietly = TRUE)) { + stop("base64enc needed for API calls") + } + } if (!api_call) { path <- paste(c( remote$username, @@ -67,15 +72,15 @@ get_remote_package_dcf = function( } } else { if (api_call) { - if (!requireNamespace("base64enc", quietly = TRUE)) { - stop("base64enc needed for API calls") - } data = httr::content(req)$content data = base64enc::base64decode(what = data) data = rawToChar(data) writeLines(data, tmp) } } + if (is.na(tmp)) { + warning("Request to GitHub API did not result in a DCF file download") + } names(tmp) = remotes return(tmp) }