| Title: | Access Files from 'Zenodo' Deposits | 
| Version: | 0.1.0 | 
| Description: | Access, download and locally cache files deposited on 'Zenodo' https://zenodo.org. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| Depends: | R (≥ 4.0.0) | 
| RoxygenNote: | 7.3.1 | 
| Imports: | checkmate, cli, curl, fs, glue, httr2, RCurl, stats, tibble, tidyr, tools | 
| Suggests: | testthat (≥ 3.0.0) | 
| Config/testthat/edition: | 3 | 
| URL: | https://rfsaldanha.github.io/zendown/, https://github.com/rfsaldanha/zendown | 
| BugReports: | https://github.com/rfsaldanha/zendown/issues | 
| Config/Needs/website: | rmarkdown | 
| NeedsCompilation: | no | 
| Packaged: | 2024-05-21 12:37:45 UTC; raphael | 
| Author: | Raphael Saldanha | 
| Maintainer: | Raphael Saldanha <raphael.de-freitas-saldanha@inria.fr> | 
| Repository: | CRAN | 
| Date/Publication: | 2024-05-21 12:50:03 UTC | 
Cache report
Description
Print a report at the console with cache statistics
Usage
cache_report(cache_type = NULL, cache_dir = NULL)
Arguments
| cache_type | character. Use  | 
| cache_dir | character. User specified cache directory for persistent cache type. | 
Value
No return value. The function prints a report on the console.
Examples
mirror_deposit(deposit_id = 10959197)
cache_report()
Delete a deposit mirror
Description
This function will delete all mirrored files stored locally.
Usage
delete_mirror(deposit_id, cache_type = NULL, cache_dir = NULL)
Arguments
| deposit_id | numeric. The Zenodo deposit id. | 
| cache_type | character. Use  | 
| cache_dir | character. User specified cache directory for persistent cache type. | 
Value
No return value. The function deletes mirrored on the system.
Examples
# https://zenodo.org/records/10959197
file_path <- zen_file(10959197, "iris.rds")
print(file_path)
file.exists(file_path)
delete_mirror(10959197)
file.exists(file_path)
Download files from a Zenodo deposit
Description
Download files from a Zenodo deposit
Usage
download_deposit(list_deposit, file_name = NULL, dest, quiet = FALSE)
Arguments
| list_deposit | data.frame or tibble. Obtained with list_deposit. | 
| file_name | character. If  | 
| dest | character. Destination folder. | 
| quiet | logical. Show download info and progress bar. | 
Value
No return value. The function downloads files to the specified destination.
Examples
res <- list_deposit(deposit_id = 10959197)
temp_dir <- tempdir()
download_deposit(list_deposit = res, dest = temp_dir, quiet = FALSE)
file.exists(file.path(temp_dir, "iris.rds"))
file.exists(file.path(temp_dir, "mtcars.rds"))
Get a list of files available at a Zenodo deposit
Description
Get a list of files available at a Zenodo deposit
Usage
list_deposit(deposit_id)
Arguments
| deposit_id | numeric. The Zenodo deposit id. | 
Value
a tibble.
Examples
# https://zenodo.org/records/10959197
list_deposit(deposit_id = 10959197)
Mirror a Zenodo deposit locally
Description
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  | 
| cache_dir | character. User specified cache directory for persistent cache type. | 
| cache_type | character. Use  | 
| 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"))
file.exists(file.path(mirror_path, "mtcars.rds"))
Access a Zenodo deposit file
Description
Get the local path to a Zenodo deposit file. It not cached in a mirror yet, it will download the file to a deposit mirror cache locally.
Usage
zen_file(
  deposit_id,
  file_name,
  cache_type = NULL,
  cache_dir = NULL,
  clear_cache = FALSE,
  quiet = FALSE
)
Arguments
| deposit_id | numeric. The Zenodo deposit id. | 
| file_name | character. If  | 
| cache_type | character. Use  | 
| cache_dir | character. User specified cache directory for persistent cache type. | 
| 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 file 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
zen_file_path <- zen_file(10959197, "iris.rds")
print(zen_file_path)
file.exists(zen_file_path)