Skip to content

Commit

Permalink
update warning + docs on versions, #59
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreyhanson committed Sep 28, 2022
1 parent 6507973 commit c83514c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
29 changes: 23 additions & 6 deletions R/wdpa_fetch.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ NULL
#' `FALSE`.
#'
#' @details
#' This function will check to see if the specified data
#' have previously been downloaded, download the data if needed,
#' and import the data.
#' This function obtains and imports data from Protected Planet.
#' By default (per `force_download = FALSE`), it will check to see if the
#' data have already been downloaded and, if so, simply import the previously
#' downloaded data.
#' It will also check to see if a newer version of the dataset is available
#' on Protected Planet (per `check_version = TRUE`) and, if so, provide an
#' alert.
#' If the latest version is not required, this alert can be safely ignored.
#' However, if the latest version of the data is required,
#' then using `force_download = TRUE` will ensure that the latest version
#' is always obtained.
#' After importing the data, it is strongly recommended to clean the data
#' prior to analysis (see [wdpa_clean()]).
#'
Expand Down Expand Up @@ -183,13 +191,22 @@ wdpa_fetch <- function(x, wait = FALSE,
### throw warning if out of date
if (input_file_date < current_file_date) {
#nocov start
warning(paste0("local data is out of date: ",
format(input_file_date, "%b %Y")))
cli::cli_alert_warning(
paste0(
"importing local data (version ",
format(input_file_date, "%b %Y"),
"); use \"force=TRUE\" if you need latest version."
)
)
#nocov end
}
} else {
## if internet not available
warning("cannot verify if version on disk is up to date.") #nocov
# nocov start
cli::cli_alert_warning(
"cannot verify if version on disk is up to date."
)
# nocov end
}
}
}
Expand Down
14 changes: 11 additions & 3 deletions man/wdpa_fetch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit c83514c

@DrMattG
Copy link

Choose a reason for hiding this comment

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

Great. Thanks!

Please sign in to comment.