graceful_download: Download a File Gracefully with Retry Mechanism

View source: R/pmlb.R

graceful_downloadR Documentation

Download a File Gracefully with Retry Mechanism

Description

Attempts to download a file from a specified URL, retrying a set number of times if the download fails. This function meets CRAN's requirement for gracefully handling the use of internet resources by catching errors and returning a warning message if the download ultimately fails.

Usage

graceful_download(url, destfile, retries = 3)

Arguments

url

Character. The URL of the file to download.

destfile

Character. The path to the destination file where the downloaded content will be saved.

retries

Integer. The maximum number of download attempts (default is 3).

Value

Logical. Returns 'TRUE' if the download succeeds, 'FALSE' otherwise.

Examples

## Not run: 
dataset_url <- "https://example.com/dataset.csv"
tmp <- tempfile(fileext = ".csv")
success <- download_file_gracefully(dataset_url, tmp)
if (!success) {
  message("Continuing gracefully without the dataset.")
}

## End(Not run)

pmlbr documentation built on April 12, 2025, 1:59 a.m.