From 450cabdf84b43fa0ef27e7518049f3bd9102d806 Mon Sep 17 00:00:00 2001 From: liugddx Date: Tue, 3 Sep 2024 23:32:00 +0800 Subject: [PATCH] 1 --- core/src/services/lakefs/core.rs | 11 +++++------ core/src/services/lakefs/lister.rs | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/core/src/services/lakefs/core.rs b/core/src/services/lakefs/core.rs index 805a372253d..5a476aceb14 100644 --- a/core/src/services/lakefs/core.rs +++ b/core/src/services/lakefs/core.rs @@ -109,7 +109,7 @@ impl LakefsCore { path: &str, delimiter: &str, amount: &Option, - after: &Option<&str>, + after: Option, ) -> Result> { let p = build_abs_path(&self.root, path); @@ -119,20 +119,19 @@ impl LakefsCore { ); if !p.is_empty() { - write!(url, "&prefix={}", percent_encode_path(&p)) - .expect("write into string must succeed"); + url.push_str(&format!("&prefix={}", percent_encode_path(&p))); } if !delimiter.is_empty() { - write!(url, "&delimiter={delimiter}").expect("write into string must succeed"); + url.push_str(&format!("&delimiter={}", delimiter)); } if let Some(amount) = amount { - write!(url, "&amount={amount}").expect("write into string must succeed"); + url.push_str(&format!("&amount={}", amount)); } if let Some(after) = after { - write!(url, "&after={after}").expect("write into string must succeed"); + url.push_str(&format!("&after={}", after)); } let mut req = Request::get(&url); diff --git a/core/src/services/lakefs/lister.rs b/core/src/services/lakefs/lister.rs index 3cd916ccfb7..65391f16d93 100644 --- a/core/src/services/lakefs/lister.rs +++ b/core/src/services/lakefs/lister.rs @@ -32,7 +32,7 @@ pub struct LakefsLister { path: String, delimiter: &'static str, amount: Option, - after: Option<&'static str>, + after: Option, } impl LakefsLister { @@ -49,7 +49,7 @@ impl LakefsLister { path, delimiter, amount, - after, + after: after.map(String::from), } } } @@ -58,7 +58,17 @@ impl oio::PageList for LakefsLister { async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> { let response = self .core - .list_objects(&self.path, &self.delimiter, &self.amount, &self.after) + .list_objects( + &self.path, + &self.delimiter, + &self.amount, + // start after should only be set for the first page. + if ctx.token.is_empty() { + self.after.clone() + } else { + None + }, + ) .await?; let status_code = response.status();