Skip to content

refactor(services/aliyun_drive): Move raw request to core #6089

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

Merged
merged 11 commits into from
Apr 27, 2025

Conversation

jorgehermo9
Copy link
Contributor

@jorgehermo9 jorgehermo9 marked this pull request as ready for review April 26, 2025 11:25
@jorgehermo9 jorgehermo9 requested a review from Xuanwo as a code owner April 26, 2025 11:25
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. releases-note/refactor The PR does a refactor on code or has a title that begins with "refactor" labels Apr 26, 2025
@@ -399,6 +399,14 @@ impl AliyunDriveCore {
self.send(req, token.as_deref()).await
}

pub async fn download(&self, download_url: &str, range: BytesRange) -> Result<Buffer> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

similar to how upload method is done

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Apr 26, 2025
.header(header::RANGE, args.range().to_header())
.body(Buffer::new())
.map_err(new_request_build_error)?;
let resp = self.core.download(&download_url, args.range()).await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as https://github.com/apache/opendal/pull/6090/files#r2061281070. Should we move both get_download_url and download(download_url) into a single method download_file in core?

Copy link
Contributor

@erickguan erickguan Apr 26, 2025

Choose a reason for hiding this comment

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

Reasonable to keep a single function.

An alternative is that AliyunDriveCore::download calls the get_download_url. Then the functions are more modular.
And I hope rustc will inline the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree with that @erickguan , thanks for the review

Copy link
Contributor

@erickguan erickguan Apr 27, 2025

Choose a reason for hiding this comment

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

You are welcome.

🚀

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 27, 2025

let download_url = self.core.get_download_url(&file.file_id).await?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored this as @erickguan suggested #6089 (comment)

.core
.get_upload_url(file_id, upload_id, Some(self.part_number))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored this as @erickguan suggested #6089 (comment)

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.

Thank you @jorgehermo9 for the PR!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 27, 2025
@Xuanwo Xuanwo merged commit aa6e0f7 into apache:main Apr 27, 2025
87 checks passed
@jorgehermo9 jorgehermo9 deleted the aliyun_drive-request-refactor branch April 27, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer releases-note/refactor The PR does a refactor on code or has a title that begins with "refactor" size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants