skip file move if file does not exist

This commit is contained in:
Patrick Schratz 2024-07-29 13:21:54 +02:00
commit 830390dc31
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -67,7 +67,7 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
{
install_package_system_dependencies(package_name, tag, platform, local_clone_dir)
},
# NB: here we need to use conditionMessage() to extract the actual error - as opposed to using $stderr for errors within the tryCatch used in the future* calls
# NB: here we need to use conditionMessage() to extract the actual error - as opposed to using $stderr for errors within the tryCatch used in the future* calls
error = function(e) {
message(sprintf("Error in installing dependencies for package %s with tag %s: %s", package_name[1], tag[1], e))
store_build_metadata(package_name[1], tag[1], platform, error_occurred = TRUE, force = TRUE, error = conditionMessage(e))
@ -169,11 +169,16 @@ build_single_tag <- function(
if (debug) {
cli::cli_alert_info('{.fun build_single_tag}: Moving package from {.path {sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag))}} to {.path {sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag)}}')
}
# remove _aarch64-unknown-linux-gnu part in filename
fs::file_move(
sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag),
sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag)
)
# double-check that file exists (some packages like https://github.com/cran/BACCO/tree/1.0-14 don't include R/ and hence don't procude a valid binary)
if (fs::file_exists(sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag))) {
# remove _aarch64-unknown-linux-gnu part in filename
fs::file_move(
sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag),
sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag)
)
} else {
cli::cli_alert_info('{.fun build_single_tag}: File for package {.pkg {package_name}} {.field {tag}} at {.path {sprintf("%s/%s_%s_R_aarch64-unknown-linux-gnu.tar.gz", dir_out_bin, package_name, tag))}} does not exist - skipping.')
}
} else {
cli::cli_alert_warning('{.fun build_single_tag}: Binary {sprintf("%s_%s.tar.gz", package_name, tag)} already exists. Skipping copy.')
}