Skip to content

Commit 4db6a80

Browse files
committed
add tidyhydat_perform
1 parent c214ebd commit 4db6a80

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

R/download.R

+3-4
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ download_hydat <- function(dl_hydat_here = NULL, ask = TRUE) {
5959
req <- httr2::request(url)
6060
req <- httr2::req_method(req, "HEAD")
6161
req <- tidyhydat_agent(req)
62-
req <- req_perform(req)
62+
req <- tidyhydat_perform(req)
6363
httr2::resp_check_status(req)
6464

6565
size <- round(as.numeric(
@@ -83,7 +83,6 @@ download_hydat <- function(dl_hydat_here = NULL, ask = TRUE) {
8383
if (!dl_overwrite) {
8484
info("HYDAT is updated on a quarterly basis, check again soon for an updated version.")
8585
}
86-
browser()
8786
if (new_hydat != existing_hydat & ask) { # New DB available or no local DB at all
8887
msg <- paste0(
8988
"This version of HYDAT is ", size, "MB in size and will take some time to download.
@@ -114,7 +113,7 @@ download_hydat <- function(dl_hydat_here = NULL, ask = TRUE) {
114113
## Download the zip file
115114
hydb_req <- httr2::request(url)
116115
hydb_req <- tidyhydat_agent(hydb_req)
117-
resp <- req_perform(hydb_req, tmp)
116+
resp <- tidyhydat_perform(hydb_req, path = tmp)
118117
httr2::resp_check_status(resp)
119118

120119
## Extract the file to a temporary dir
@@ -158,7 +157,7 @@ hy_remote <- function() {
158157
network_check(hy_base_url())
159158

160159
req <- httr2::request(hy_base_url())
161-
req <- httr2::req_perform(req)
160+
req <- tidyhydat_perform(req)
162161
resp <- httr2::resp_check_status(req)
163162

164163

R/utils.R

+6
Original file line numberDiff line numberDiff line change
@@ -256,4 +256,10 @@ hy_expected_tbls <- function() {
256256
is_mac <- function() {
257257
system_info <- Sys.info()
258258
grepl("darwin", tolower(system_info["sysname"]))
259+
}
260+
261+
tidyhydat_perform <- function(req, ...) {
262+
req <- httr2::req_retry(req, max_tries = 5)
263+
req <- httr2::req_progress(req)
264+
httr2::req_perform(req, ...)
259265
}

0 commit comments

Comments
 (0)