diff --git a/R/outpack_helpers.R b/R/outpack_helpers.R index 117399ef..68cd5057 100644 --- a/R/outpack_helpers.R +++ b/R/outpack_helpers.R @@ -121,10 +121,16 @@ orderly_copy_files <- function(..., files, dest, overwrite = TRUE, file_export(root, id, plan$there, plan$here, dest, overwrite), not_found_error = function(e) { if (id %in% root$index$unpacked()) { + ## The most likely reason for things to have failed is that + ## the user has deleted part of the archive. + name <- outpack_metadata_core(id, root)$name + packet_exists <- file.exists( + file.path(root$path, root$config$core$path_archive, name, id)) + reason <- if (packet_exists) "locally modified" else "deleted" cmd <- sprintf( 'orderly2::orderly_validate_archive("%s", action = "orphan")', id) cli::cli_abort( - c("Unable to copy files, due to corrupt packet {id}", + c("Unable to copy files, due to {reason} packet {id}", i = "Consider '{cmd}' to remove this packet from consideration"), parent = e) } else if (!as_orderly_search_options(options)$allow_remote) { diff --git a/tests/testthat/test-run.R b/tests/testthat/test-run.R index d92cd92f..e6ea573b 100644 --- a/tests/testthat/test-run.R +++ b/tests/testthat/test-run.R @@ -1025,7 +1025,7 @@ test_that("cope with manually deleted packets, exclude from deps", { "Failed to run report") expect_equal( err$parent$message, - set_names(paste("Unable to copy files, due to corrupt packet", id), + set_names(paste("Unable to copy files, due to deleted packet", id), "")) cmd <- sprintf('orderly2::orderly_validate_archive("%s", action = "orphan")', id) @@ -1060,7 +1060,7 @@ test_that("cope with corrupted packets, exclude from deps", { "Failed to run report") expect_equal( err$parent$message, - set_names(paste("Unable to copy files, due to corrupt packet", id), + set_names(paste("Unable to copy files, due to locally modified packet", id), "")) cmd <- sprintf('orderly2::orderly_validate_archive("%s", action = "orphan")', id) @@ -1072,7 +1072,7 @@ test_that("cope with corrupted packets, exclude from deps", { expect_s3_class(err$parent$parent, "not_found_error") expect_equal( err$parent$parent$message, - sprintf("File 'data.rds' in 'data/%s' is corrupt", id), "") + sprintf("File 'data.rds' in 'data/%s' is corrupt", id)) expect_null(err$parent$parent$body) expect_match( err$parent$parent$parent$message,