From 90c425c6f956b852e8eb0a0cc5c69ca2b3b1aec9 Mon Sep 17 00:00:00 2001 From: Fonti Kar Date: Thu, 25 Jul 2024 13:32:31 +1000 Subject: [PATCH] Timeout fix (#99) * Increased time out * Added ignore to Rbuildignore --- .Rbuildignore | 1 + R/global.R | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.Rbuildignore b/.Rbuildignore index f01e415..da446b9 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,3 +11,4 @@ ignore/ + diff --git a/R/global.R b/R/global.R index dcff4b0..f858583 100644 --- a/R/global.R +++ b/R/global.R @@ -203,7 +203,7 @@ check_and_download_update <- function() { message("No internet connection or data source down, try again later") return(NULL) } - response <- httr::GET(url) + response <- httr::GET(url, httr::timeout(200)) release_data <- jsonlite::fromJSON(httr::content(response, "text")) @@ -219,6 +219,13 @@ check_and_download_update <- function() { cat("New version found:", latest_version, "\n") # Download binary files + + # Get original timeout option + original_timeout <- getOption("timeout") + + # Increase timeout + options(timeout = 300) + for (i in 1:nrow(release_data$assets)) { asset_name <- release_data$assets[i, "name"] binary_url <- release_data$assets[i, "browser_download_url"] @@ -230,6 +237,10 @@ check_and_download_update <- function() { mode = "wb" ) } + + # Burn down + options(timeout = original_timeout) + writeLines(latest_version, file.path(infinity_file_path, "infinitylistversion.txt")) #creating a bug elsewhere cat("Update complete.\n")