Skip to content

Commit b88b976

Browse files
committed
fix incremental pulls in get_bucket to not assume exact field order (related to #414)
1 parent 3e635ab commit b88b976

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/get_bucket.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ get_bucket <- function(bucket,
5656
marker = if (!is.null(r[["NextMarker"]])) r[["NextMarker"]] else tail(r[names(r) == "Contents"], 1)[["Contents"]][["Key"]]
5757
)
5858
extra <- s3HTTP(verb = "GET", bucket = bucket, query = query, parse_response = parse_response, ...)
59-
new_r <- c(r, tail(extra, -5))
59+
## append only the "Contents" entries
60+
new_r <- c(r, extra[names(extra) == "Contents"])
61+
## update specific entries in the result from the next batch
6062
new_r[["MaxKeys"]] <- as.character(as.integer(r[["MaxKeys"]]) + as.integer(extra[["MaxKeys"]]))
6163
new_r[["IsTruncated"]] <- extra[["IsTruncated"]]
64+
new_r[["Marker"]] <- NULL ## remove any existing markers
65+
new_r[["NextMarker"]] <- extra[["NextMarker"]] ## can be NULL which is fine
6266
attr(new_r, "x-amz-id-2") <- attr(r, "x-amz-id-2")
6367
attr(new_r, "x-amz-request-id") <- attr(r, "x-amz-request-id")
6468
attr(new_r, "date") <- attr(r, "date")

0 commit comments

Comments
 (0)