From 75428f0f3d9da6768e5e692acd3c3dea1383f1b8 Mon Sep 17 00:00:00 2001 From: wlandau Date: Thu, 24 Aug 2023 16:06:34 -0400 Subject: [PATCH] gcp fixes --- R/class_gcp.R | 22 +++++++--------------- tests/testthat/helper-aws.R | 4 ++-- tests/testthat/helper-gcp.R | 2 +- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/R/class_gcp.R b/R/class_gcp.R index 1a567558d..ac7c96a83 100644 --- a/R/class_gcp.R +++ b/R/class_gcp.R @@ -185,29 +185,21 @@ store_ensure_correct_hash.tar_gcp <- function(store, storage, deployment) { #' @export store_has_correct_hash.tar_gcp <- function(store) { - path <- store$file$path - bucket <- store_gcp_bucket(path) - key <- store_gcp_key(path) - version <- store_gcp_version(path) - hash <- store_gcp_hash( - key = key, - bucket = bucket, - version = version, - verbose = store$resources$gcp$verbose %|||% FALSE - ) + hash <- store_gcp_hash(store = store) !is.null(hash) && identical(hash, store$file$hash) } -store_gcp_hash <- function(key, bucket, version, verbose) { +store_gcp_hash <- function(store) { + path <- store$file$path old_try_attempts <- getOption("googleAuthR.tryAttempts") on.exit(options(googleAuthR.tryAttempts = old_try_attempts), add = TRUE) option <- store$resources$network$max_tries if_any(is.null(option), NULL, options(googleAuthR.tryAttempts = option)) head <- gcp_gcs_head( - key = key, - bucket = bucket, - version = version, - verbose = verbose + key = store_gcp_key(path), + bucket = store_gcp_bucket(path), + version = store_gcp_version(path), + verbose = store$resources$gcp$verbose %|||% FALSE ) head$metadata[["targets-hash"]] } diff --git a/tests/testthat/helper-aws.R b/tests/testthat/helper-aws.R index f7f3dfec3..101fbb87b 100644 --- a/tests/testthat/helper-aws.R +++ b/tests/testthat/helper-aws.R @@ -9,7 +9,7 @@ skip_if_no_aws <- function() { random_bucket_name <- function() { paste0( - "targets-testing-bucket-", + "targets-test-bucket-", substr( digest::digest(tempfile(), algo = "sha256"), start = 0, @@ -50,7 +50,7 @@ aws_s3_delete_targets_buckets <- function(client = paws.storage::s3()) { ) ) buckets <- grep( - pattern = "^targets-testing-bucket-", + pattern = "^targets-test-bucket-", x = buckets, value = TRUE ) diff --git a/tests/testthat/helper-gcp.R b/tests/testthat/helper-gcp.R index 901c5f1cb..d693edb39 100644 --- a/tests/testthat/helper-gcp.R +++ b/tests/testthat/helper-gcp.R @@ -15,7 +15,7 @@ gcp_gcs_delete_targets_buckets <- function() { project <- Sys.getenv("GCE_DEFAULT_PROJECT_ID") buckets <- googleCloudStorageR::gcs_list_buckets(projectId = project)$name buckets <- grep( - pattern = "^targets-testing-bucket-", + pattern = "^targets-test-bucket-", x = buckets, value = TRUE )