fixes to archive_packages

This commit is contained in:
Patrick Schratz 2024-08-31 09:22:02 +02:00
commit 5c26632cc3
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -31,6 +31,8 @@ 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))
}
@ -38,16 +40,16 @@ archive_package <- function(
# only archive if more than one package exists in the root
if (length(all_versions) > 1) {
# get most recent version from CRAN
last_version <- available.packages("https://cloud.r-project.org")[.x, "Version"]
last_version <- available.packages("https://cloud.r-project.org/src/contrib")[.x, "Version"]
# check if last version is available in repo
if (any(grepl(last_version, all_versions))) {
index <- which(grepl(last_version, all_versions))
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)
for (i in versions) {
if (any(grepl(i, all_versions))) {
index <- which(grepl(i, all_versions))
if (any(grepl(i, all_versions, fixed = TRUE))) {
index <- which(grepl(sprintf("_%s.tar.gz", i), all_versions))
old_versions <- all_versions[-index]
break
}