Skip to contents

Mirror an entire Zenodo deposit or a specific file locally. The mirror is a folder with the deposit files created at the cache folder of the operating system.

Usage

mirror_deposit(
  deposit_id,
  file_name = NULL,
  cache_dir = NULL,
  cache_type = NULL,
  clear_cache = FALSE,
  quiet = FALSE
)

Arguments

deposit_id

numeric. The Zenodo deposit id.

file_name

character. If NULL, all files from the file list. If a file name is specified, only this file will be downloaded.

cache_dir

character. User specified cache directory for persistent cache type.

cache_type

character. Use temporary to a session temporary folder, persistent for a persistent cache folder or NULL to use the environment default. Check the section Cache Type for more details.

clear_cache

logical. If the mirror already exists, clear its content.

quiet

logical. Show download info and progress bar.

Value

a string with the mirror path.

Cache type

The Zenodo mirror will be cached locally on a system folder. This folder can be temporary, being cleared when the R session is ended, or persistent across sections and reboots.

If the cache_type argument is NULL (the default) the package will check first the environment variable zendown_cache_type. If set, the package will use its value. If not set, a temporary cache folder will be used as default.

You can set an environment variable with usethis::edit_r_environ() and write as bellow for a persistent cache storage.

zendown_cache_type = "persistent"

After saving the file, remember to restart the session. With this setting, the cache will be persistent and stored at the directory given by tools::R_user_dir("zendown", which = "cache")

You may also use a different folder for persistent storage by setting the zendown_cache_dir environment variable. For example:

zendown_cache_dir = C:\my_cache\

If you set the cache_type argument directly as temporary or persistent, it will override the environment setting.

Examples

# https://zenodo.org/records/10959197
mirror_path <- mirror_deposit(deposit_id = 10959197)
file.exists(file.path(mirror_path, "iris.rds"))
#> [1] TRUE
file.exists(file.path(mirror_path, "mtcars.rds"))
#> [1] TRUE