Skip to content

Commit

Permalink
Fix RDS version for older versions of R #129
Browse files Browse the repository at this point in the history
  • Loading branch information
andrie committed Nov 24, 2022
1 parent c066e01 commit 31a947a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 8 additions & 0 deletions R/makeRepo.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,15 @@ updateRepoIndex <- function(path, type = "source", Rversion = R.version) {
n <- lapply(type, function(t) {
pkgPath <- repoBinPath(path = path, type = t, Rversion = Rversion)
if (grepl("mac.binary", t)) t <- "mac.binary"
# browser()
write_packages(dir = pkgPath, type = t, r_version = Rversion)
if (twodigitRversion(Rversion) < "3.5.0") {
pfiles <- list.files(path = pkgPath, pattern = "PACKAGES.rds", recursive = TRUE, full.names = TRUE)
for (f in pfiles) {
pf <- readRDS(f)
saveRDS(pf, file = f, version = 2)
}
}
})
names(n) <- type
n
Expand Down
10 changes: 1 addition & 9 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ download_packages <- function(pkgs, destdir, available, repos, contriburl, type,
# Thin wrapper around write_PACKAGES
write_packages <- function(dir, type, r_version) {
r_version <- twodigitRversion(r_version)
if (r_version >= "3.5.0") {
tools::write_PACKAGES(dir = dir, type = type)
} else {
if (getRversion() >= "3.5.0") {
tools::write_PACKAGES(dir = dir, type = type, rds_compress = 2)
} else {
tools::write_PACKAGES(dir = dir, type = type)
}
}
tools::write_PACKAGES(dir = dir, type = type)
}


4 changes: 2 additions & 2 deletions tests/testthat/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ mock_write_packages <- function(dir, type = "source", r_version) {
rownames(db) <- db[, "Package"]
r_version <- twodigitRversion(r_version)
if (r_version >= "3.5.0") {
saveRDS(db, file.path(dir, "PACKAGES.rds"), compress = "xz")
saveRDS(db, file.path(dir, "PACKAGES.rds"))
} else {
saveRDS(db, file.path(dir, "PACKAGES.rds"), compress = "xz", version = 2)
saveRDS(db, file.path(dir, "PACKAGES.rds"), version = 2)
}
}
np
Expand Down

0 comments on commit 31a947a

Please sign in to comment.