Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
liugddx committed Sep 3, 2024
1 parent 64f86f4 commit 450cabd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
11 changes: 5 additions & 6 deletions core/src/services/lakefs/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl LakefsCore {
path: &str,
delimiter: &str,
amount: &Option<usize>,
after: &Option<&str>,
after: Option<String>,
) -> Result<Response<Buffer>> {
let p = build_abs_path(&self.root, path);

Expand All @@ -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);
Expand Down
16 changes: 13 additions & 3 deletions core/src/services/lakefs/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct LakefsLister {
path: String,
delimiter: &'static str,
amount: Option<usize>,
after: Option<&'static str>,
after: Option<String>,
}

impl LakefsLister {
Expand All @@ -49,7 +49,7 @@ impl LakefsLister {
path,
delimiter,
amount,
after,
after: after.map(String::from),
}
}
}
Expand All @@ -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();
Expand Down

0 comments on commit 450cabd

Please sign in to comment.