Skip to content

Commit a24d363

Browse files
committed
Fix crash when using cache with no-output operators
1 parent 295b659 commit a24d363

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎pkg_build/extra-R/cdo.R‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,15 @@ cdo_execute <- function(
212212
) {
213213
check_cdo_version(get_cdo())
214214

215+
use_cache <- FALSE
215216
# Need to first build the hash to make temp output deterministic
216217
if (isTRUE(cache)) {
217218
if (operation$operator$n_output != 1) {
218219
cli::cli_alert_warning(
219220
"Cache only works with oeprations with 1 file output."
220221
)
221222
}
223+
use_cache <- TRUE
222224
hash_current <- rlang::hash(list(
223225
get_cdo_version(get_cdo()),
224226
build_operation(
@@ -248,7 +250,7 @@ cdo_execute <- function(
248250
options_replace = options_replace
249251
)
250252

251-
if (isTRUE(cache)) {
253+
if (use_cache) {
252254
hash_file <- paste0(operation$output, ".hash")
253255

254256
if (file.exists(operation$output)) {
@@ -299,7 +301,7 @@ cdo_execute <- function(
299301
attr(operation$output, "size") <- sum(file.size(operation$output))
300302
}
301303

302-
if (isTRUE(cache)) {
304+
if (use_cache) {
303305
writeLines(hash_current, hash_file)
304306
}
305307

0 commit comments

Comments
 (0)