readd pause arg

This commit is contained in:
Patrick Schratz 2024-09-02 09:48:55 +02:00
commit 3525ebfbd0
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -11,7 +11,8 @@ archive_package <- function(
local_build_root = ".",
endpoint = "https://s3.eu-central-003.backblazeb2.com",
region = "eu-central-003",
bucket = "devxy-arm64-r-binaries") {
bucket = "devxy-arm64-r-binaries",
pause = NULL) {
s3fs::s3_file_system(
aws_access_key_id = Sys.getenv("AWS_ACCESS_KEY_ID"),
aws_secret_access_key = Sys.getenv("AWS_SECRET_ACCESS_KEY"),
@ -31,7 +32,6 @@ archive_package <- function(
files <- s3fs::s3_dir_ls(remote_bin_dir)
foo <- lapply(package_name, function(.x) {
cli::cli_h3("Processing {.pkg {.x}}")
if (!s3fs::s3_dir_exists(sprintf("%s/Archive/%s", remote_bin_dir, .x))) {
s3fs::s3_dir_create(sprintf("%s/Archive/%s", remote_bin_dir, .x))
@ -46,7 +46,7 @@ archive_package <- function(
index <- which(grepl(sprintf("_%s.tar.gz", last_version), all_versions, fixed = TRUE))
old_versions <- all_versions[-index]
} else {
versions = rev(pak::pkg_history(.x)$Version)
versions <- rev(pak::pkg_history(.x)$Version)
for (i in versions) {
if (any(grepl(i, all_versions, fixed = TRUE))) {
index <- which(grepl(sprintf("_%s.tar.gz", i), all_versions))
@ -58,6 +58,9 @@ archive_package <- function(
cli::cli_alert("{.fun archive_package}: Archiving {.field {basename(old_versions)}}, keeping {.field {basename(all_versions[index])}}.")
s3fs::s3_file_move(old_versions, sprintf("%s/Archive/%s/%s", remote_bin_dir, .x, basename(old_versions)), overwrite = TRUE)
cli::cli_alert_success("{.fun archive_package}: Successfully archived package {.pkg {.x}}.")
if (!is.null(pause)) {
Sys.sleep(pause)
}
}
cli::cli_alert("{.fun archive_package}: Skipping {.pkg {.x}} as only one package versions exists.")
})