Skip to content

Commit

Permalink
fix error checking bucket existence v0.16.3
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondben committed Sep 23, 2024
1 parent 8b4ca32 commit 92891d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: bowerbird
Type: Package
Title: Keep a Collection of Sparkly Data Resources
Version: 0.16.2
Version: 0.16.3
Authors@R: c(person("Ben", "Raymond", email = "ben.raymond@aad.gov.au", role = c("aut", "cre")),
person("Michael", "Sumner", role = "aut"),
person("Miles", "McBain", email = "miles.mcbain@gmail.com", role = c("rev", "ctb")),
Expand Down
10 changes: 6 additions & 4 deletions R/aws_s3.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,12 @@ aws_list_objects <- function(s3_args, create = FALSE) {
chk <- aws_fun(aws.s3::bucketlist, s3_args[setdiff(names(s3_args), "bucket")])
##chk <- tryCatch(aws_fun(aws.s3::bucket_exists, s3_args), error = function(e) stop("no can do"))
## bucket_exists returns 404 error if the bucket does not exist, 403 error if it exists but is inaccessible to these credentials?
if ((nrow(chk) < 1 || !s3_args$bucket %in% chk$Bucket) && isTRUE(create)) {
chk <- tryCatch(aws_fun(aws.s3::put_bucket, s3_args), error = function(e) stop("Could not create bucket. ", conditionMessage(e)))
} else {
stop("bucket does not exist")
if ((nrow(chk) < 1 || !s3_args$bucket %in% chk$Bucket)) {
if (isTRUE(create)) {
chk <- tryCatch(aws_fun(aws.s3::put_bucket, s3_args), error = function(e) stop("Could not create bucket. ", conditionMessage(e)))
} else {
stop("bucket does not exist")
}
}
## get bucket contents
tryCatch({
Expand Down

0 comments on commit 92891d4

Please sign in to comment.