Skip to content

Commit

Permalink
Group by region and endpoint when batch-deleting cloud objects
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau-lilly committed Dec 4, 2023
1 parent 4657a6f commit a195181
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
15 changes: 12 additions & 3 deletions R/class_aws.R
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,19 @@ store_exist_object.tar_aws <- function(store, name = NULL) {
#' @export
store_delete_objects.tar_aws <- function(store, meta, batch_size, verbose) {
aws <- store$resources$aws
buckets <- map_chr(meta$path, ~store_aws_bucket(.x))
for (bucket in unique(buckets)) {
subset <- meta[buckets == bucket,, drop = FALSE] # nolint
meta$bucket_group <- map_chr(
x = meta$path,
f = ~paste(
store_aws_bucket(.x),
store_aws_region(.x),
store_aws_endpoint(.x),
sep = "|"
)
)
for (group in unique(meta$bucket_group)) {
subset <- meta[meta$bucket_group == group,, drop = FALSE] # nolint
example_path <- subset$path[[1L]]
bucket <- store_aws_bucket(example_path)
region <- store_aws_region(example_path)
endpoint <- store_aws_endpoint(example_path)
objects <- map(
Expand Down
20 changes: 14 additions & 6 deletions R/class_gcp.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,21 @@ store_delete_object.tar_gcp <- function(store, name = NULL) {
#' @export
store_delete_objects.tar_gcp <- function(store, meta, batch_size, verbose) {
gcp <- store$resources$gcp
buckets <- map_chr(meta$path, ~store_gcp_bucket(.x))
for (bucket in unique(buckets)) {
subset <- meta[buckets == bucket,, drop = FALSE] # nolint
meta$bucket_group <- map_chr(
x = meta$path,
f = ~paste(
store_gcp_bucket(.x),
store_gcp_region(.x),
sep = "|"
)
)
for (group in unique(meta$bucket_group)) {
subset <- meta[meta$bucket_group == group,, drop = FALSE] # nolint
for (index in seq_len(nrow(subset))) {
path <- subset$path[[index]]
key <- store_gcp_key(path)
version <- store_gcp_version(path)
example_path <- subset$path[[index]]
bucket <- store_gcp_bucket(example_path)
key <- store_gcp_key(example_path)
version <- store_gcp_version(example_path)
message <- paste(
"could not object %s from gcp bucket %s.",
"You may need to delete it manually.\nMessage: "
Expand Down

0 comments on commit a195181

Please sign in to comment.