From 3a696ea837dbad8b8e88509d1f068cc64f0a6a17 Mon Sep 17 00:00:00 2001 From: wlandau-lilly Date: Wed, 22 May 2019 00:16:49 -0400 Subject: [PATCH] Fix #878 --- NEWS.md | 4 ++++ R/exec-meta.R | 8 -------- R/exec-store.R | 7 ++++++- tests/testthat/test-utils.R | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4cba4d958..3c74dd841 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # Version 7.3.0.9000 +## Bug fixes + +- Do not rehash large imported files every `make()` [#878](https://github.com/ropensci/drake/issues/878). + ## New features - Add `drake_slice()` to help split data across multiple targets. Related: [#77](https://github.com/ropensci/drake/issues/77), [#685](https://github.com/ropensci/drake/issues/685), [#833](https://github.com/ropensci/drake/issues/833). diff --git a/R/exec-meta.R b/R/exec-meta.R index ddc2a4515..e64a59cb3 100644 --- a/R/exec-meta.R +++ b/R/exec-meta.R @@ -169,14 +169,6 @@ rehash_dir <- function(dir, config) { ) } -safe_rehash_storage <- function(target, config) { - if (file.exists(decode_path(target, config))) { - rehash_storage(target = target, config = config) - } else { - NA_character_ - } -} - should_rehash_storage <- function(filename, new_mtime, old_mtime, size_cutoff) { do_rehash <- storage_size(filename) < size_cutoff | new_mtime > old_mtime diff --git a/R/exec-store.R b/R/exec-store.R index 221eb78da..c9cef0b1a 100644 --- a/R/exec-store.R +++ b/R/exec-store.R @@ -90,9 +90,14 @@ store_object <- function(target, value, meta, config) { } store_file <- function(target, meta, config) { + if (meta$imported) { + value <- storage_hash(target = target, config = config) + } else { + value <- rehash_storage(target = target, config = config) + } store_object( target = target, - value = safe_rehash_storage(target = target, config = config), + value = value, meta = meta, config = config ) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 196ca8fbc..772cf5315 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -278,7 +278,8 @@ test_with_dir("drake_slice on arrays", { } ) lst$along <- margin - out <- do.call(abind::abind, lst) + # unfixable partial arg match warnings: + out <- suppressWarnings(do.call(abind::abind, lst)) expect_equivalent(x, out) } }