From 10f89901a342682eda6ba3320261569e40f09176 Mon Sep 17 00:00:00 2001 From: Egor Kotov Date: Sat, 26 Oct 2024 22:29:33 +0200 Subject: [PATCH] improve robusness of data dir check --- R/get.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/get.R b/R/get.R index 77e8b5f..f2791d7 100644 --- a/R/get.R +++ b/R/get.R @@ -298,12 +298,14 @@ spod_get_data_dir <- function(quiet = FALSE) { if (data_dir_env == "") { if (isFALSE(quiet)) warning("Warning: SPANISH_OD_DATA_DIR is not set. Using the temporary directory, which is not recommended, as the data will be deleted when the session ends.\n\n To set the data directory, use `Sys.setenv(SPANISH_OD_DATA_DIR = '/path/to/data')` or set SPANISH_OD_DATA_DIR permanently in the environment by editing the `.Renviron` file locally for current project with `usethis::edit_r_environ('project')` or `file.edit('.Renviron')` or globally for all projects with `usethis::edit_r_environ('user')` or `file.edit('~/.Renviron')`.") data_dir_env <- tempdir() # if not set, use the temp directory + } else { + data_dir_env <- fs::path_real(data_dir_env) } # check if dir exists and create it if it doesn't if (!fs::dir_exists(data_dir_env)) { fs::dir_create(data_dir_env) } - return(fs::path_real(data_dir_env)) + return(data_dir_env) } #' retrieves the zones data