Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions core/services/vercel-blob/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl VercelBlobCore {
let p = build_abs_path(&self.root, path);
// Vercel blob use an unguessable random id url to download the file
// So we use list to get the url of the file and then use it to download the file
let resp = self.list(ctx, &p, Some(1)).await?;
let resp = self.list(ctx, &p, Some(1), None).await?;

// Use the mtach url to download the file
let url = resolve_blob(resp.blobs, p);
Expand Down Expand Up @@ -161,7 +161,7 @@ impl VercelBlobCore {
pub async fn head(&self, ctx: &OperationContext, path: &str) -> Result<Response<Buffer>> {
let p = build_abs_path(&self.root, path);

let resp = self.list(ctx, &p, Some(1)).await?;
let resp = self.list(ctx, &p, Some(1), None).await?;

let url = resolve_blob(resp.blobs, p);

Expand Down Expand Up @@ -194,7 +194,7 @@ impl VercelBlobCore {
) -> Result<Response<Buffer>> {
let from = build_abs_path(&self.root, from);

let resp = self.list(ctx, &from, Some(1)).await?;
let resp = self.list(ctx, &from, Some(1), None).await?;

let from_url = resolve_blob(resp.blobs, from);

Expand Down Expand Up @@ -229,6 +229,7 @@ impl VercelBlobCore {
ctx: &OperationContext,
prefix: &str,
limit: Option<usize>,
cursor: Option<&str>,
) -> Result<ListResponse> {
let prefix = if prefix == "/" { "" } else { prefix };

Expand All @@ -241,6 +242,10 @@ impl VercelBlobCore {
url.push_str(&format!("&limit={limit}"))
}

if let Some(cursor) = cursor {
url.push_str(&format!("&cursor={}", percent_encode_path(cursor)));
}

let req = Request::get(&url);

let req = self.sign(req);
Expand Down Expand Up @@ -271,7 +276,7 @@ impl VercelBlobCore {
pub async fn vercel_delete_blob(&self, ctx: &OperationContext, path: &str) -> Result<()> {
let p = build_abs_path(&self.root, path);

let resp = self.list(ctx, &p, Some(1)).await?;
let resp = self.list(ctx, &p, Some(1), None).await?;

let url = resolve_blob(resp.blobs, p);

Expand Down
15 changes: 12 additions & 3 deletions core/services/vercel-blob/src/lister.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,21 @@ impl oio::PageList for VercelBlobLister {
async fn next_page(&self, ctx: &mut oio::PageContext) -> Result<()> {
let p = build_abs_path(&self.core.root, &self.path);

let resp = self.core.list(&self.ctx, &p, self.limit).await?;
let cursor = if ctx.token.is_empty() {
None
} else {
Some(ctx.token.as_str())
};

let resp = self.core.list(&self.ctx, &p, self.limit, cursor).await?;

ctx.done = !resp.has_more;

if let Some(cursor) = resp.cursor {
ctx.token = cursor;
match resp.cursor {
Some(cursor) => ctx.token = cursor,
// More pages were reported but nothing was handed back to resume from. Stopping
// truncates the listing; the alternative is re-requesting the same page forever.
None => ctx.done = true,
}

for blob in resp.blobs {
Expand Down
Loading