From f5917b3badea1dbbb5e7f4f33f7030ee8d2d8b5a Mon Sep 17 00:00:00 2001 From: Raphael Taylor-Davies Date: Wed, 25 Oct 2023 23:34:32 +0100 Subject: [PATCH] Support list_with_offset for GCS --- object_store/src/gcp/client.rs | 6 ++++-- object_store/src/gcp/mod.rs | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/object_store/src/gcp/client.rs b/object_store/src/gcp/client.rs index 558a6f8d2a84..18ffd6fcd0d4 100644 --- a/object_store/src/gcp/client.rs +++ b/object_store/src/gcp/client.rs @@ -376,8 +376,6 @@ impl ListClient for GoogleCloudStorageClient { page_token: Option<&str>, offset: Option<&str>, ) -> Result<(ListResult, Option)> { - assert!(offset.is_none()); // Not yet supported - let credential = self.get_credential().await?; let url = format!("{}/{}", self.config.base_url, self.bucket_name_encoded); @@ -399,6 +397,10 @@ impl ListClient for GoogleCloudStorageClient { query.push(("max-keys", max_results)) } + if let Some(offset) = offset { + query.push(("start-after", offset)) + } + let response = self .client .request(Method::GET, url) diff --git a/object_store/src/gcp/mod.rs b/object_store/src/gcp/mod.rs index 6512a8b036c5..04e971a47472 100644 --- a/object_store/src/gcp/mod.rs +++ b/object_store/src/gcp/mod.rs @@ -156,6 +156,14 @@ impl ObjectStore for GoogleCloudStorage { self.client.list(prefix) } + fn list_with_offset( + &self, + prefix: Option<&Path>, + offset: &Path, + ) -> BoxStream<'_, Result> { + self.client.list_with_offset(prefix, offset) + } + async fn list_with_delimiter(&self, prefix: Option<&Path>) -> Result { self.client.list_with_delimiter(prefix).await }