Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(services/vercel_blob): support vercel blob #4103

Merged
merged 1 commit into from
Jan 31, 2024
Merged

Conversation

hoslo
Copy link
Contributor

@hoslo hoslo commented Jan 31, 2024

fixes #2191

@hoslo
Copy link
Contributor Author

hoslo commented Jan 31, 2024

@Xuanwo blob fails to pass the test of test_write_with_special_chars, after debugging, i feel that it is a vercel error. Maybe you can help me check it

@Xuanwo
Copy link
Member

Xuanwo commented Jan 31, 2024

@Xuanwo blob fails to pass the test of test_write_with_special_chars, after debugging, i feel that it is a vercel error. Maybe you can help me check it

This test is not mentioned in the documentation. Perhaps we can simply ignore it for the Vercel blob.

@Xuanwo Xuanwo closed this Jan 31, 2024
@Xuanwo Xuanwo deleted the support-vercel-blob branch January 31, 2024 07:23
@Xuanwo Xuanwo restored the support-vercel-blob branch January 31, 2024 07:23
@Xuanwo Xuanwo reopened this Jan 31, 2024
@Xuanwo
Copy link
Member

Xuanwo commented Jan 31, 2024

Sorry for the mistake operation

@hoslo hoslo force-pushed the support-vercel-blob branch 3 times, most recently from ea4f17d to 410b9c0 Compare January 31, 2024 07:53
@hoslo
Copy link
Contributor Author

hoslo commented Jan 31, 2024

Why does seafile container not start?

@Xuanwo
Copy link
Member

Xuanwo commented Jan 31, 2024

Seems seafile pushed a new tag serval hours ago:

image

Maybe we can change the tag in docker-compose file to use the old one until they addressed. Would you like to submit a new PR for this?

ref: https://hub.docker.com/r/seafileltd/seafile-mc/tags

@Xuanwo
Copy link
Member

Xuanwo commented Jan 31, 2024

Fixed in #4107, please try again after merge with main.

@hoslo hoslo force-pushed the support-vercel-blob branch 2 times, most recently from 5ba2571 to c592c2c Compare January 31, 2024 13:04
core/src/services/vercel_blob/core.rs Show resolved Hide resolved
core/src/services/vercel_blob/core.rs Outdated Show resolved Hide resolved
core/src/services/vercel_blob/core.rs Outdated Show resolved Hide resolved
core/src/services/vercel_blob/core.rs Outdated Show resolved Hide resolved
core/src/services/vercel_blob/core.rs Outdated Show resolved Hide resolved
core/src/services/vercel_blob/core.rs Outdated Show resolved Hide resolved
core/src/services/vercel_blob/core.rs Outdated Show resolved Hide resolved
core/src/services/vercel_blob/core.rs Outdated Show resolved Hide resolved
@hoslo hoslo force-pushed the support-vercel-blob branch 3 times, most recently from 2707f5c to 5fd43df Compare January 31, 2024 14:39
return Err(Error::new(ErrorKind::NotFound, "Blob not found"));
}

// Use the first url to download the file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems pathname not checked?

return Err(Error::new(ErrorKind::NotFound, "Blob not found"));
}

let url = &blobs[0].url;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here. The first blob returned in list might not be the blob we want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example, we have files like aa. If users trying to get file a, they will got aa.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad. It should have matched pathname, fixed.

pub async fn copy(&self, from: &str, to: &str) -> Result<Response<IncomingAsyncBody>> {
let from = build_abs_path(&self.root, from);

let resp = self.list(&from, Some(1)).await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pattern show a lot. Maybe we can add a function called resolve_blob? We can implement the get blob logic and leave detailed comments there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


let status = resp.status();

match status {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can write like this to improvie the readability

if status != StatusCode::OK {
    return Err(parse_error(resp).await?);
}

// other logic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// In this case, we want to create a new MPU.
req = req.header("x-mpu-action", "create");

req = req.header("x-add-random-suffix", "0");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These headers are used in multiple places. We can extract them as constants and add comments to explain their meaning and possible values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Member

@Xuanwo Xuanwo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@Xuanwo Xuanwo merged commit 18bdf3a into main Jan 31, 2024
235 checks passed
@Xuanwo Xuanwo deleted the support-vercel-blob branch January 31, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

services: Add support Vercel Blob
2 participants