Skip to content

Commit

Permalink
Added more options when pulling down the SewerRat binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Apr 26, 2024
1 parent 178f6df commit a73e17e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SewerRat
Version: 0.2.2
Date: 2024-04-25
Version: 0.2.3
Date: 2024-04-26
Title: Client for the SewerRat API
Description:
Search metadata files across a shared filesystem via the SewerRat API.
Expand Down
12 changes: 8 additions & 4 deletions R/startSewerRat.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#' @param db String containing a path to the SQLite database.
#' @param port Integer specifying the port to use for hosting the service.
#' If \code{NULL}, a free port is randomly selected.
#' @param wait Integer specifying the number of seconds to wait for service initialization.
#' @param overwrite Logical scalar indicating whether to redownload the Gobbler binary.
#' @param version String containing the desired version of the Gobbler binary.
#'
#' @return For \code{startSewerRat}, a list indicating whether a new service was set up, along with the port number and URL to use in other \pkg{SewerRat} functions.
#'
Expand All @@ -23,7 +26,7 @@
#'
#' @export
#' @importFrom utils download.file
startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL) {
startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL, wait = 1, version = "0.1.2", overwrite = FALSE) {
if (!is.null(running$active)) {
return(list(new=FALSE, port=running$port, url=assemble_url(running$port)))
}
Expand Down Expand Up @@ -52,9 +55,9 @@ startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL) {
}

desired <- sprintf("SewerRat-%s-%s", os, arch)
exe <- file.path(cache, desired)
if (!file.exists(exe)) {
url <- paste0("https://github.com/ArtifactDB/SewerRat/releases/download/latest/", desired)
exe <- file.path(cache, paste0(desired, version))
if (!file.exists(exe) || overwrite) {
url <- paste0("https://github.com/ArtifactDB/SewerRat/releases/download/", version, "/", desired)
tmp <- tempfile()
if (download.file(url, tmp)) {
stop("failed to download the SewerRat binary")
Expand All @@ -76,6 +79,7 @@ startSewerRat <- function(db=tempfile(fileext=".sqlite3"), port=NULL) {

script <- system.file("scripts", "deploy.sh", package="SewerRat", mustWork=TRUE)
pid <- system2(script, c(shQuote(exe), shQuote(db), shQuote(port)), stdout=TRUE)
Sys.sleep(wait)

process <- new.env()
process$pid <- pid
Expand Down
14 changes: 13 additions & 1 deletion man/startSewerRat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a73e17e

Please sign in to comment.