diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml index 7cc0a0d..74ec7b0 100644 --- a/.github/workflows/rhub.yaml +++ b/.github/workflows/rhub.yaml @@ -64,8 +64,7 @@ jobs: with: token: ${{ secrets.RHUB_TOKEN }} job-config: ${{ matrix.config.job-config }} - env: - _R_CHECK_THINGS_IN_OTHER_DIRS_: true + other-platforms: needs: setup if: ${{ needs.setup.outputs.platforms != '[]' }} @@ -94,5 +93,3 @@ jobs: with: job-config: ${{ matrix.config.job-config }} token: ${{ secrets.RHUB_TOKEN }} - env: - _R_CHECK_THINGS_IN_OTHER_DIRS_: true diff --git a/R/zzz.R b/R/zzz.R index 883cb02..41711d9 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -12,6 +12,32 @@ assign( envir = ct_env ) +.onAttach <- function(libname, pkgname) { + ## throw a warning, if a cache in the non-compliant directory is detected + ## but only if there is actually any files in this directory + ## pointing to the migrating function + if (( + rappdirs::user_cache_dir('comtradr') != + tools::R_user_dir('comtradr', which = 'cache') + ) && + (length(list.files(rappdirs::user_cache_dir('comtradr'))) > 0 | + length(list.files( + rappdirs::user_cache_dir('comtradr_bulk') + )) > 0)) { + packageStartupMessage(cli::cli_bullets( + c( + "In the last version of comtradr the cache location has been changed, because it was not CRAN compliant. You can:", #nolint + '*' = 'Migrate the cache and clean old files with {.run ct_migrate_cache()}', + '*' = 'Ignore this warning, a new cache is created automatically.', + '*' = "Delete your old cache manually with:", + '*' = "{.run rappdirs::user_cache_dir('comtradr') |> list.files(full.names = T) |> file.remove()}", #nolint + ' ' = "and", + '*' = "{.run rappdirs::user_cache_dir('comtradr_bulk') |> list.files(full.names = T) |> file.remove()}") #nolint + )) + } +} + + .onLoad <- function(libname, pkgname) { max_size_env <- Sys.getenv("COMTRADR_CACHE_MAX_SIZE") @@ -47,23 +73,7 @@ assign( value = cache, envir = rlang::ns_env("comtradr")) - ## throw a warning, if a cache in the non-compliant directory is detected - ## but only if there is actually any files in this directory - ## pointing to the migrating function - if( - (rappdirs::user_cache_dir('comtradr')!= - tools::R_user_dir('comtradr', which = 'cache')) && - (length(list.files(rappdirs::user_cache_dir('comtradr')))>0| - length(list.files(rappdirs::user_cache_dir('comtradr_bulk')))>0)){ - cli::cli_bullets(c("In the last version of comtradr the cache location has been changed, because it was not CRAN compliant. You can:", #nolint - '*' = 'Migrate the cache and clean old files with {.run ct_migrate_cache()}', - '*' = 'Ignore this warning, a new cache is created automatically.', - '*' = "Delete your old cache manually with:", - '*' = "{.run rappdirs::user_cache_dir('comtradr') |> list.files(full.names = T) |> file.remove()}", #nolint - ' ' = "and", - '*' = "{.run rappdirs::user_cache_dir('comtradr_bulk') |> list.files(full.names = T) |> file.remove()}") #nolint - ) - } + }