|
1 | 1 | #' @importFrom utils file_test sessionInfo |
2 | 2 | future_cache_path <- local({ |
3 | | - ## The path used for this session |
4 | | - path <- NULL |
| 3 | + ## The subfolder used for this session |
| 4 | + dir <- NULL |
5 | 5 |
|
6 | 6 | function(root_path = Sys.getenv("R_FUTURE_CACHE_PATH", ".future"), absolute = TRUE, create = TRUE) { |
7 | | - if (is.null(path)) { |
| 7 | + if (is.null(dir)) { |
8 | 8 | id <- basename(tempdir()) |
9 | 9 | id <- gsub("Rtmp", "", id, fixed = TRUE) |
10 | 10 | timestamp <- format(Sys.time(), format = "%Y%m%d_%H%M%S") |
11 | | - dir <- sprintf("%s-%s", timestamp, id) |
12 | | - path_tmp <- file.path(root_path, dir) |
13 | | - if (create && !file_test("-d", path_tmp)) { |
14 | | - dir.create(path_tmp, recursive = TRUE) |
15 | | - pathname_tmp <- file.path(path_tmp, "sessioninfo.txt") |
16 | | - writeLines(capture_output(print(sessionInfo())), con = pathname_tmp) |
17 | | - } |
18 | | - path <<- path_tmp |
| 11 | + dir <<- sprintf("%s-%s", timestamp, id) |
19 | 12 | } |
| 13 | + |
| 14 | + path <- file.path(root_path, dir) |
| 15 | + if (create && !file_test("-d", path)) { |
| 16 | + dir.create(path, recursive = TRUE) |
| 17 | + pathname <- file.path(path, "sessioninfo.txt") |
| 18 | + writeLines(capture_output(print(sessionInfo())), con = pathname) |
| 19 | + } |
| 20 | + |
20 | 21 | if (absolute) path <- normalizePath(path, mustWork = FALSE) |
21 | 22 |
|
22 | 23 | path |
|
0 commit comments