ensure_files_available_from_manifest: Ensure the files described in a manifest are available in the...

View source: R/manifest.R

ensure_files_available_from_manifestR Documentation

Ensure the files described in a manifest are available in the file cache.

Description

Like ensure_files_available, but the files are described in a single declarative manifest (one row per file) instead of three parallel vectors. A manifest can be a CSV file (e.g., shipped with the package in inst/extdata) or a data.frame, see read_manifest for the expected format.

Usage

ensure_files_available_from_manifest(
  pkg_info,
  manifest,
  base_url = NULL,
  files_are_binary = NULL,
  on_errors = "warn",
  download = TRUE,
  num_connections = getOption("pkgfilecache.num_connections", 2),
  num_retries = 2
)

Arguments

pkg_info

named list. Package identifier, see get_pkg_info() on how to get one.

manifest

string or data.frame. The manifest to use, see read_manifest. Either the path to a CSV file, or a data.frame with the manifest columns.

base_url

string or NULL. Base URL to derive the download URL for files that have no explicit URL, see read_manifest. Ignored for files with an explicit url entry.

files_are_binary

logical vector. For each file, whether it is binary. Only required on Windows, when files need to be downloaded. See curl::curl_download docs for details. Ignored when download is FALSE.

on_errors

string. What to do if getting the files failed. One of c("warn", "stop", "ignore"). See ensure_files_available for details.

download

logical. Whether to try downloading missing files. Defaults to TRUE. Existing files (with correct MD5 if available) will never be downloaded. Set to FALSE to only check which files are available without downloading anything.

num_connections

integer. The number of parallel connections to use when downloading files, see ensure_files_available. Defaults to 2, or to the value of the R option pkgfilecache.num_connections if it is set.

num_retries

integer. How many times to retry downloading files that failed, in addition to the first attempt, see ensure_files_available. Defaults to 2.

Value

Named list, like for ensure_files_available: the entries "available" and "missing" contain the manifest paths (as '/'-separated strings) that are available in, or missing from, the local file cache. The entry "file_status" is a logical vector in manifest row order indicating for each file whether it is available.

Examples

   pkg_info = get_pkg_info("mypackage")
   # A manifest as a data.frame: two files, URLs derived from base_url.
   manifest = data.frame(path = c("sub/file1.txt", "file2.txt"),
                         stringsAsFactors = FALSE)
   # Only check availability, do not download anything (download = FALSE).
   # The files are missing, so a warning is expected (see 'on_errors').
   res = suppressWarnings(ensure_files_available_from_manifest(pkg_info, manifest,
         base_url = "https://example.com/data/",
         download = FALSE))


pkgfilecache documentation built on Sept. 1, 2026, 1:08 a.m.