diff --git a/DESCRIPTION b/DESCRIPTION index f61ca2fd..03fce2c1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: orderly Title: Lightweight Reproducible Reporting -Version: 1.4.4 +Version: 1.4.5 Description: Order, create and store reports from R. By defining a lightweight interface around the inputs and outputs of an analysis, a lot of the repetitive work for reproducible research diff --git a/R/deduplicate.R b/R/deduplicate.R index 2b5ba76a..acb478de 100644 --- a/R/deduplicate.R +++ b/R/deduplicate.R @@ -68,6 +68,11 @@ orderly_deduplicate <- function(root = NULL, locate = TRUE, dry_run = TRUE, orderly_deduplicate_info <- function(config) { + report_metadata <- list.files(path_metadata(config$root)) + if (length(report_metadata) > 0) { + stop(paste("Cannot deduplicate archive reports have been pulled from", + "remote with recursive = FALSE.")) + } con <- orderly_db("destination", config) on.exit(DBI::dbDisconnect(con)) @@ -98,8 +103,13 @@ orderly_deduplicate_info <- function(config) { unname(tapply(files$inode, files$hash, function(x) x[[1L]]))[i] ## Quick check: - stopifnot(all(vlapply(split(files, files$hash), function(x) - all(x$inode_first == x$inode[[1]])))) + can_deduplicate <- all(vlapply(split(files, files$hash), function(x) { + isTRUE(all(x$inode_first == x$inode[[1]])) + })) + if (!can_deduplicate) { + stop(paste("Cannot deduplicate archive as database references files", + "which don't exist.")) + } ## Classify the files into different states files$state <- rep("distinct", nrow(files)) diff --git a/docker/build_website b/docker/build_website index c9192c4c..86441e25 100755 --- a/docker/build_website +++ b/docker/build_website @@ -22,6 +22,7 @@ DB_NAME=orderly SCHEMASPY_NAME=vimc/orderly-schemaspy DOCS_DIR=$PACKAGE_ROOT/docs +VIGNETTES_DIR=$PACKAGE_ROOT/vignettes docker build \ --build-arg ORDERLY_BASE=$ORDERLY_BASE \ @@ -65,6 +66,7 @@ docker run --rm \ --network=$DB_NW \ -w /orderly \ -v $DOCS_DIR:/orderly/docs \ + -v $VIGNETTES_DIR:/orderly/vignettes \ --user "$USER_STR" \ $ORDERLY_DEV \ Rscript -e 'pkgdown::build_site(document = FALSE)' diff --git a/tests/testthat/test-deduplicate.R b/tests/testthat/test-deduplicate.R index 4815b990..1e63dad2 100644 --- a/tests/testthat/test-deduplicate.R +++ b/tests/testthat/test-deduplicate.R @@ -172,3 +172,32 @@ test_that("relink error handling", { expect_error(relink(from, to), "Some error linking") expect_true(all(fs::file_info(c(from, to))$inode == info)) }) + + +test_that("deduplicate fails if file is missing", { + skip_on_cran() + path <- orderly_example("demo") + id1 <- orderly_run("minimal", root = path, echo = FALSE) + id2 <- orderly_run("minimal", root = path, echo = FALSE) + orderly_commit(id1, root = path) + orderly_commit(id2, root = path) + + unlink(file.path(path, "archive", "minimal", id1, "script.R")) + + expect_error(orderly_deduplicate_info(orderly_config(path)), paste( + "Cannot deduplicate archive as database references files", + "which don't exist.")) +}) + +test_that("deduplicate fails if report pulled from remote recursive FALSE", { + skip_on_cran() + dat <- prepare_orderly_remote_example() + id3 <- orderly_run("depend", root = dat$path_remote, echo = FALSE) + orderly_commit(id3, root = dat$path_remote) + + orderly_pull_archive("depend", root = dat$config, remote = dat$remote, + recursive = FALSE) + expect_error(orderly_deduplicate_info(dat$config), paste( + "Cannot deduplicate archive reports have been pulled from", + "remote with recursive = FALSE.")) +})