fix metadata overwrite logic

This commit is contained in:
Patrick Schratz 2024-07-31 13:07:04 +02:00
commit 14cf69331d
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -93,12 +93,11 @@ build_binary_package <- function(package_name, tag = NULL, codename = NULL,
tryCatch(
{
p()
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir, platform = platform, debug = debug)
dump <- build_single_tag(x, y, dir_out_bin, local_clone_dir, platform = platform, debug = debug, force = force)
# if for some reason an underlying error didnt' get caught in the tryCatch calls, we check again here for the existence of the binary file on disk and mark the build as failed if it is not found
tarball_name <- sprintf("%s_%s.tar.gz", x, y)
if (fs::file_exists(sprintf("%s/%s", local_bin_path, tarball_name))) {
store_build_metadata(x, y, platform, error_occurred = FALSE, force = force)
cli::cli_alert_success("Successfully built package {.pkg {x}} with tag {.field {y}}.")
} else {
cli::cli_alert_warning("Error in building package {.pkg {x}} with tag {.field {y}}: Uncommon/unspecific error during build.")
@ -147,7 +146,8 @@ build_single_tag <- function(
platform,
dir_out_bin,
local_clone_dir,
debug = FALSE) {
debug = FALSE,
force = FALSE) {
cli::cli_alert("{.fun build_single_tag}: (1/3) Cloning package {.pkg {package_name}} with tag {.field {tag}}.")
local_clone_dir_single <- sprintf("%s/%s_%s", local_clone_dir, package_name, tag)
@ -213,19 +213,9 @@ build_single_tag <- function(
cli::cli_alert_warning("DEBUG: file_size: {file_size}")
}
# skip DB connection if package already exists
if (file.exists(sprintf("%s/%s_%s.tar.gz", dir_out_bin, package_name, tag))) {
con <- DBI::dbConnect(RPostgres::Postgres(),
dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io",
port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS")
)
dbExecute(con,
"UPDATE single_builds SET build_duration = $1, size = $2 WHERE package_name = $3 and platform = $4 and tag = $5",
params = list(
total_build_time, file_size, package_name, platform, tag
)
)
dbDisconnect(con)
tarball_name <- sprintf("%s_%s.tar.gz", package_name, tag)
if (fs::file_exists(sprintf("%s/%s", dir_out_bin, tarball_name))) {
store_build_metadata(package_name, tag, platform, error_occurred = FALSE, force = force, build_duration = total_build_time, size = file_size)
}
}