Skip to content

Commit

Permalink
Merge pull request #1106 from OldLipe/feat/appy_prop
Browse files Browse the repository at this point in the history
Add `.mpc_clean_token_cache` function to clean MPC tokens on the fly
  • Loading branch information
OldLipe committed Apr 17, 2024
2 parents 8b80507 + d7d8bcd commit f0a09ff
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion R/api_source_mpc.R
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@
if (!nzchar(access_key)) {
access_key <- NULL
}
# Clean old tokens cached in rstac
.mpc_clean_token_cache()
items_info <- suppressWarnings(
rstac::items_sign(
items_info, sign_fn = rstac::sign_planetary_computer(
Expand All @@ -338,7 +340,7 @@
collection,
stac_query, ...,
tiles = NULL,
orbit = "descending") {
orbit = "descending") {
`.source_items_new.mpc_cube_sentinel-1-grd`(
source = source,
collection = collection,
Expand Down Expand Up @@ -406,6 +408,8 @@
if (!nzchar(access_key)) {
access_key <- NULL
}
# Clean old tokens cached in rstac
.mpc_clean_token_cache()
items_info <- suppressWarnings(
rstac::items_sign(
items_info,
Expand Down Expand Up @@ -467,6 +471,8 @@
if (!nzchar(access_key)) {
access_key <- NULL
}
# Clean old tokens cached in rstac
.mpc_clean_token_cache()
items <- suppressWarnings(
rstac::items_sign(
items,
Expand Down Expand Up @@ -560,3 +566,12 @@
tiles = tiles)

}

.mpc_clean_token_cache <- function() {
mpc_token <- get("ms_token", envir = asNamespace("rstac"), inherits = TRUE)
cached_tokens <- names(mpc_token)
lapply(cached_tokens, function(cached_token) {
assign(cached_token, NULL, envir = mpc_token)
})
return(invisible(NULL))
}

0 comments on commit f0a09ff

Please sign in to comment.