Skip to content

Commit f7e865c

Browse files
committed
invalidate cache on (serialized) client config change
1 parent 3827d61 commit f7e865c

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

R/botor.R

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ botor_client <- function(service, type = c('client', 'resource'), cache = TRUE,
8989
get(service, envir = clients, inherits = FALSE),
9090
error = function(e) NULL)
9191

92-
if (cache == TRUE && !is.null(client) && attr(client, 'uuid') == botor_session_uuid()) {
92+
client_params <- list(...)
93+
if (cache == TRUE && !is.null(client) &&
94+
attr(client, 'uuid') == botor_session_uuid() &&
95+
## compare custom client/resource parameters
96+
all.equal(client_params, attr(client, 'botor_client_params')) &&
97+
## compare serialized configs
98+
all.equal(client_params$config$`__dict__`, attr(client, 'botor_client_params')$config$`__dict__`)) {
9399
return(client)
94100
}
95101

@@ -98,6 +104,7 @@ botor_client <- function(service, type = c('client', 'resource'), cache = TRUE,
98104
} else {
99105
client <- botor()$resource(service, ...)
100106
}
107+
attr(client, 'botor_client_params') <- client_params
101108

102109
if (cache == FALSE) {
103110
return(client)

R/s3.R

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@
55
#' @importFrom logger log_trace log_debug log_info log_warn log_error
66
#' @param disable_signing boolean if requests should be signed. Set to \code{FALSE} when interacting with public S3 buckets requiring unauthenticated access.
77
s3 <- function(disable_signing = getOption('botor-s3-disable-signing')) {
8-
client <- botor_client('s3', type = 'resource', cache = FALSE)
9-
if (isTRUE(disable_signing)) {
10-
client$meta$client$meta$events$register(
11-
'choose-signer.s3.*',
12-
require_python_module('botocore')$handlers$disable_signing)
13-
}
14-
client
8+
botocore <- require_python_module('botocore')
9+
botor_client('s3', type = 'resource', config = botocore$config$Config(
10+
signature_version = if (isTRUE(disable_signing)) botocore$UNSIGNED else 's3v4'
11+
))
1512
}
1613

1714

0 commit comments

Comments
 (0)