Skip to content

Comments

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

Merged
Xuanwo merged 11 commits intoapache:mainfrom
jorgehermo9:aliyun_drive-request-refactor
Apr 27, 2025
Merged

refactor(services/aliyun_drive): Move raw request to core#6089
Xuanwo merged 11 commits intoapache:mainfrom
jorgehermo9:aliyun_drive-request-refactor

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
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
Member

@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
Member

@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
serde_json::from_reader(res.reader()).map_err(new_json_serialize_error)?;
let resp = self.core.download(&file.file_id, args.range()).await?;

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)

let res = self
if let Err(err) = self
.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