Skip to content

Commit

Permalink
Skip .data fallback in webr::install()
Browse files Browse the repository at this point in the history
  • Loading branch information
georgestagg committed Sep 11, 2024
1 parent 4655e96 commit cd9d911
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions packages/webr/R/install.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,12 @@ install <- function(packages,
if (!quiet) message(paste("Downloading webR package:", pkg))

if (mount) {
# Try mounting `.tgz` as v2.0 image, fallback to `.data` v1.0 image
# Try mounting `.tgz` as v2.0 VFS image, fallback to extracting the .tgz
tryCatch({
install_vfs_image(repo, lib, pkg, pkg_ver, ".tgz")
install_vfs_image(repo, lib, pkg, pkg_ver)
next
}, error = function(cnd) {
warning(paste(cnd$message, "Falling back to `.data` filesystem image."))
})

tryCatch({
install_vfs_image(repo, lib, pkg, pkg_ver, ".data")
next
}, error = function(cnd) {
warning(paste(cnd$message, "Falling back to copying archive contents."))
warning(paste(cnd$message, "Falling back to traditional `.tgz` extraction."))
})
}

Expand All @@ -102,8 +95,8 @@ install_tgz <- function(repo, lib, pkg, pkg_ver) {
)
}

install_vfs_image <- function(repo, lib, pkg, pkg_ver, ext) {
data_url <- file.path(repo, paste0(pkg, "_", pkg_ver, ext))
install_vfs_image <- function(repo, lib, pkg, pkg_ver) {
data_url <- file.path(repo, paste0(pkg, "_", pkg_ver, ".tgz"))
mountpoint <- file.path(lib, pkg)
mount(mountpoint, data_url)
}

0 comments on commit cd9d911

Please sign in to comment.