Skip to content

Commit c476334

Browse files
derive temp directory from env variable
1 parent 47f1b45 commit c476334

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

R/zzz.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@
2424
}
2525

2626
delete_temp_directory_if_empty <- function(path) {
27-
rlang::warn("here are all the env variables:")
28-
print(Sys.getenv())
27+
path <- normalizePath(path)
2928
if (getRversion() < package_version("4.0.0")) {
3029
return(FALSE)
3130
}
31+
3232
designated_cache_path <- normalizePath(tools::R_user_dir("R.cache", which = "cache"))
33-
match_cache_dir <- grepl(
34-
paste0("start", designated_cache_path), paste0("start", path),
35-
fixed = TRUE
36-
)
37-
if (match_cache_dir || grepl("^(/var/|/tmp/|/private/)", path)) {
33+
is_in_tools_cache <- startsWith(path, designated_cache_path)
34+
temp_dir <- normalizePath(Sys.getenv("TMPDIR", Sys.getenv("TMP")))
35+
is_in_generic_cache <- startsWith(path, temp_dir)
36+
if (is_in_tools_cache || is_in_generic_cache) {
3837
all_files <- list.files(path,
3938
full.names = TRUE,
4039
recursive = TRUE,

0 commit comments

Comments
 (0)