Skip to content

Commit 72c95b2

Browse files
committed
debug modify dataset
1 parent 5d5f38b commit 72c95b2

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎R/api.R‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ get_datasets_metadata = function(dataset_DOI,
426426
#' @param dataset_DOI A vector of character string representing the DOI of datasets that will be process.
427427
#' @param metadata_path A vector of character string for the paths of json files containing the datasets metadata.
428428
#' @param wait_time An integer for the time in seconds to wait between requests. By default, 2 seconds.
429-
#' @param n_tries An integer for the maximum number of tries to reach dataverse server. By default, 3 tries.
429+
#' @param n_retries An integer for the maximum number of retries to reach dataverse server. By default, 3 retries.
430430
#' @param BASE_URL A character string for the base URL of the Dataverse API. By default, it uses the value from the environment variable `BASE_URL`.
431431
#' @param API_TOKEN A character string for the API token required to authenticate the request. By default, it uses the value from the environment variable `API_TOKEN`.
432432
#' @param verbose If FALSE, no processing informations are displayed. By default, TRUE.
@@ -440,7 +440,7 @@ modify_datasets = function(dataverse,
440440
dataset_DOI,
441441
metadata_path,
442442
wait_time=2,
443-
n_tries=3,
443+
n_retries=3,
444444
BASE_URL=Sys.getenv("BASE_URL"),
445445
API_TOKEN=Sys.getenv("API_TOKEN"),
446446
verbose=TRUE) {
@@ -462,20 +462,20 @@ modify_datasets = function(dataverse,
462462
body=mjson$datasetVersion,
463463
encode="json")
464464

465-
attempt = 1
465+
attempt = 0
466466
while (httr::status_code(response) == 500 &
467467
httr::content(response, "text") == "{}" &
468-
attempt < n_tries) {
468+
attempt < n_retries) {
469469
response = httr::PUT(modify_url,
470470
httr::add_headers("X-Dataverse-key"=API_TOKEN),
471471
body=mjson$datasetVersion,
472472
encode="json")
473473
attempt = attempt + 1
474474
Sys.sleep(wait_time)
475475
}
476-
if (attempt >= n_tries) {
476+
if (attempt >= n_retries) {
477477
stop("Dataverse server returned empty response after ",
478-
n_tries, " attempts.")
478+
n_retries, " attempts.")
479479
}
480480
if (httr::status_code(response) != 200) {
481481
stop(paste0(httr::status_code(response), " ",

0 commit comments

Comments
 (0)