Skip to content

Commit

Permalink
gcp fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Aug 24, 2023
1 parent 045d59b commit 75428f0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
22 changes: 7 additions & 15 deletions R/class_gcp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
}
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/helper-aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
)
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/helper-gcp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit 75428f0

Please sign in to comment.