From 841fa2decf454ab3b5a6bd2d596abfa01303b375 Mon Sep 17 00:00:00 2001 From: Martin Studer Date: Mon, 23 Sep 2019 17:56:14 +0200 Subject: [PATCH 1/2] Relax package path assumptions in download_version_url; closes r-lib/remotes#440 --- R/install-version.R | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/R/install-version.R b/R/install-version.R index d2956c7f..580888d3 100644 --- a/R/install-version.R +++ b/R/install-version.R @@ -127,9 +127,12 @@ download_version_url <- function(package, version, repos, type) { # Grab the latest one: only happens if pulled from CRAN package.path <- row.names(info)[nrow(info)] } else { - package.path <- paste(package, "/", package, "_", version, ".tar.gz", + package.filename <- paste(package, "_", version, ".tar.gz", sep = "") - if (!(package.path %in% row.names(info))) { + idx <- endsWith(row.names(info), package.filename) + if(any(idx)) { + package.path <- row.names(info)[idx][1L] + } else { stop(sprintf("version '%s' is invalid for package '%s'", version, package)) } From d856b4cb8bea1e85d7c36c60d77dd75296a71d21 Mon Sep 17 00:00:00 2001 From: Martin Studer Date: Mon, 23 Sep 2019 21:58:34 +0200 Subject: [PATCH 2/2] Replace use of endsWith with substr for backwards compatibility --- R/install-version.R | 6 ++++-- inst/install-github.R | 9 +++++++-- install-github.R | 9 +++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/R/install-version.R b/R/install-version.R index 580888d3..63b339bb 100644 --- a/R/install-version.R +++ b/R/install-version.R @@ -129,9 +129,11 @@ download_version_url <- function(package, version, repos, type) { } else { package.filename <- paste(package, "_", version, ".tar.gz", sep = "") - idx <- endsWith(row.names(info), package.filename) + rn <- row.names(info) + idx <- substr(rn, nchar(rn) - nchar(package.filename) + 1, + nchar(rn)) == package.filename if(any(idx)) { - package.path <- row.names(info)[idx][1L] + package.path <- rn[idx][1L] } else { stop(sprintf("version '%s' is invalid for package '%s'", version, package)) diff --git a/inst/install-github.R b/inst/install-github.R index 8a6f0239..973155bb 100644 --- a/inst/install-github.R +++ b/inst/install-github.R @@ -3973,9 +3973,14 @@ function(...) { # Grab the latest one: only happens if pulled from CRAN package.path <- row.names(info)[nrow(info)] } else { - package.path <- paste(package, "/", package, "_", version, ".tar.gz", + package.filename <- paste(package, "_", version, ".tar.gz", sep = "") - if (!(package.path %in% row.names(info))) { + rn <- row.names(info) + idx <- substr(rn, nchar(rn) - nchar(package.filename) + 1, + nchar(rn)) == package.filename + if(any(idx)) { + package.path <- rn[idx][1L] + } else { stop(sprintf("version '%s' is invalid for package '%s'", version, package)) } diff --git a/install-github.R b/install-github.R index 8a6f0239..973155bb 100644 --- a/install-github.R +++ b/install-github.R @@ -3973,9 +3973,14 @@ function(...) { # Grab the latest one: only happens if pulled from CRAN package.path <- row.names(info)[nrow(info)] } else { - package.path <- paste(package, "/", package, "_", version, ".tar.gz", + package.filename <- paste(package, "_", version, ".tar.gz", sep = "") - if (!(package.path %in% row.names(info))) { + rn <- row.names(info) + idx <- substr(rn, nchar(rn) - nchar(package.filename) + 1, + nchar(rn)) == package.filename + if(any(idx)) { + package.path <- rn[idx][1L] + } else { stop(sprintf("version '%s' is invalid for package '%s'", version, package)) }