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/onedrive): Rewrite the method signatures using OpWrite #3091

Merged
merged 2 commits into from
Sep 16, 2023
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
8 changes: 4 additions & 4 deletions core/src/services/onedrive/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand All @@ -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)
}

Expand All @@ -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,
Expand All @@ -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)
}

Expand Down
9 changes: 2 additions & 7 deletions core/src/services/onedrive/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -109,7 +104,7 @@ impl OneDriveWriter {
.backend
.onedrive_chunked_upload(
&session_response.upload_url,
None,
&OpWrite::default(),
offset,
chunk_end,
total_len,
Expand Down
Loading