This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
The following commit(s) were added to refs/heads/main by this push:
new 055e4300d feat(services/onedrive): Rewrite the method signatures using
OpWrite (#3091)
055e4300d is described below
commit 055e4300d007969e08ad339b3217771457516234
Author: Au <[email protected]>
AuthorDate: Sat Sep 16 11:20:26 2023 +0800
feat(services/onedrive): Rewrite the method signatures using OpWrite (#3091)
* feat(services/onedrive): Rewrite the method signatures using OpWrite
* feat(services/onedrive): make cargo clippy happy
---
core/src/services/onedrive/backend.rs | 8 ++++----
core/src/services/onedrive/writer.rs | 9 ++-------
2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/core/src/services/onedrive/backend.rs
b/core/src/services/onedrive/backend.rs
index 0001d8685..0a7952e4a 100644
--- a/core/src/services/onedrive/backend.rs
+++ b/core/src/services/onedrive/backend.rs
@@ -257,7 +257,7 @@ impl OnedriveBackend {
&self,
path: &str,
size: Option<usize>,
- content_type: Option<&str>,
+ args: &OpWrite,
body: AsyncBody,
) -> Result<Response<IncomingAsyncBody>> {
let url = format!(
@@ -274,7 +274,7 @@ impl OnedriveBackend {
req = req.header(header::CONTENT_LENGTH, size)
}
- if let Some(mime) = content_type {
+ if let Some(mime) = args.content_type() {
req = req.header(header::CONTENT_TYPE, mime)
}
@@ -286,7 +286,7 @@ impl OnedriveBackend {
pub(crate) async fn onedrive_chunked_upload(
&self,
url: &str,
- content_type: Option<&str>,
+ args: &OpWrite,
offset: usize,
chunk_end: usize,
total_len: usize,
@@ -303,7 +303,7 @@ impl OnedriveBackend {
let size = chunk_end - offset + 1;
req = req.header(header::CONTENT_LENGTH, size.to_string());
- if let Some(mime) = content_type {
+ if let Some(mime) = args.content_type() {
req = req.header(header::CONTENT_TYPE, mime)
}
diff --git a/core/src/services/onedrive/writer.rs
b/core/src/services/onedrive/writer.rs
index 326035acb..f6ee5e969 100644
--- a/core/src/services/onedrive/writer.rs
+++ b/core/src/services/onedrive/writer.rs
@@ -64,12 +64,7 @@ impl OneDriveWriter {
async fn write_simple(&self, bs: Bytes) -> Result<()> {
let resp = self
.backend
- .onedrive_upload_simple(
- &self.path,
- Some(bs.len()),
- self.op.content_type(),
- AsyncBody::Bytes(bs),
- )
+ .onedrive_upload_simple(&self.path, Some(bs.len()), &self.op,
AsyncBody::Bytes(bs))
.await?;
let status = resp.status();
@@ -109,7 +104,7 @@ impl OneDriveWriter {
.backend
.onedrive_chunked_upload(
&session_response.upload_url,
- None,
+ &OpWrite::default(),
offset,
chunk_end,
total_len,