
Decide whether a remote ZIP is worth downloading for a data archive
Source:R/zip-peek.R
zip_decision.RdPeeks inside the zip (see zip_peek()) and classifies its entries. A zip is
worth downloading if it contains actual data or a codebook; a zip of only
stimuli/software is better linked than mirrored.
Usage
zip_decision(
url,
skip_types = "materials",
cache = FALSE,
skip_on_api_limit = FALSE,
size = NULL
)Arguments
- url
the zip's download URL, or the path of a zip already on disk
- skip_types
data_type(s) that don't count as worth-downloading content (e.g.
"materials")- cache
passed to
zip_peek(): ifTRUE, reuse an on-disk cached peek across R sessions instead of re-peeking the archive.- skip_on_api_limit
passed to
zip_peek(): ifTRUE, a confirmed exhausted rate-limit bucket is treated as a failed peek instead of waiting out the host's reset.- size
passed to
zip_peek(): the zip's size in bytes when already known (e.g. from the repository's file listing), which saves a HEAD request.NULL(the default) asks the host.
Value
a list with worth (TRUE/FALSE, or NA when the peek failed so
the caller can fall back to downloading), reason, n_entries, types
(table of inner types), and contents (the peeked data.frame or NULL).
Examples
if (requireNamespace("zip", quietly = TRUE)) {
# a zip of the demo repository; a URL of a zip on a server works the same
z <- file.path(tempdir(), "stroop_effect_paper.zip")
zip::zipr(z, file.path(demofile("repo"), c("data", "code", "README.md")))
dec <- zip_decision(z)
dec[c("worth", "reason")]
}
#> $worth
#> [1] TRUE
#>
#> $reason
#> [1] "contains archivable content"
#>