Skip to content

Commit 7cf57a4

Browse files
Report on batchtools cache folder [#97]
1 parent f5d4b12 commit 7cf57a4

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: future.batchtools
2-
Version: 0.12.2-9911
2+
Version: 0.12.2-9912
33
Depends:
44
R (>= 3.2.0),
55
parallelly,

R/BatchtoolsFutureBackend-class.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ print.BatchtoolsFutureBackend <- function(x, ...) {
140140
printf("batchtools resources:\n")
141141
str(resources)
142142

143+
path <- future_cache_path()
144+
printf("Cache directory: %s\n", dir_info(path))
145+
143146
invisible(x)
144147
}
145148

R/utils.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,27 @@ file_info <- function(file) {
165165
}
166166

167167

168+
#' @importFrom utils file_test
169+
dir_info <- function(dir) {
170+
if (is.null(dir) || is.na(dir)) return("<NA>")
171+
if (file_test("-d", dir)) {
172+
files <- dir(path = dir, full.names = TRUE)
173+
info <- file.info(files)
174+
info <- info[info[["isdir"]], "mtime"]
175+
if (length(info) == 0) {
176+
info <- "0 folders"
177+
} else {
178+
period <- range(info)
179+
period <- format(period, "%FT%T")
180+
info <- sprintf("%d folders; %s/%s", length(info), period[1], period[2])
181+
}
182+
} else {
183+
info <- "<non-existing>"
184+
}
185+
sprintf("%s (%s)", sQuote(dir), info)
186+
}
187+
188+
168189
assert_no_positional_args_but_first <- function(call = sys.call(sys.parent())) {
169190
ast <- as.list(call)
170191
if (length(ast) <= 2L) return()

0 commit comments

Comments
 (0)