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 6187b6dd1 feat(services/azblob): Rewrite the method signatures using 
OpWrite (#3068)
6187b6dd1 is described below

commit 6187b6dd1ce3b9c2d2645bc6907ef32fafd5fdce
Author: Au <[email protected]>
AuthorDate: Thu Sep 14 23:16:32 2023 +0800

    feat(services/azblob): Rewrite the method signatures using OpWrite (#3068)
    
    * feat(services/azblob)!: Rewrite the method signatures using OpWrite
    
    * chore(services/azblob): use OpWrite::default instead of Default::default
---
 core/src/services/azblob/backend.rs | 19 ++++++++++++-------
 core/src/services/azblob/core.rs    | 14 ++++++--------
 core/src/services/azblob/writer.rs  | 11 ++++-------
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/core/src/services/azblob/backend.rs 
b/core/src/services/azblob/backend.rs
index 3ba390c13..967cdd712 100644
--- a/core/src/services/azblob/backend.rs
+++ b/core/src/services/azblob/backend.rs
@@ -557,9 +557,12 @@ impl Accessor for AzblobBackend {
     }
 
     async fn create_dir(&self, path: &str, _: OpCreateDir) -> 
Result<RpCreateDir> {
-        let mut req =
-            self.core
-                .azblob_put_blob_request(path, Some(0), None, None, 
AsyncBody::Empty)?;
+        let mut req = self.core.azblob_put_blob_request(
+            path,
+            Some(0),
+            &OpWrite::default(),
+            AsyncBody::Empty,
+        )?;
 
         self.core.sign(&mut req).await?;
 
@@ -682,10 +685,12 @@ impl Accessor for AzblobBackend {
                 v.if_match(),
                 v.override_content_disposition(),
             )?,
-            PresignOperation::Write(_) => {
-                self.core
-                    .azblob_put_blob_request(path, None, None, None, 
AsyncBody::Empty)?
-            }
+            PresignOperation::Write(_) => self.core.azblob_put_blob_request(
+                path,
+                None,
+                &OpWrite::default(),
+                AsyncBody::Empty,
+            )?,
         };
 
         self.core.sign_query(&mut req).await?;
diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs
index 5eb46f464..e493ff1ab 100644
--- a/core/src/services/azblob/core.rs
+++ b/core/src/services/azblob/core.rs
@@ -245,8 +245,7 @@ impl AzblobCore {
         &self,
         path: &str,
         size: Option<u64>,
-        content_type: Option<&str>,
-        cache_control: Option<&str>,
+        args: &OpWrite,
         body: AsyncBody,
     ) -> Result<Request<AsyncBody>> {
         let p = build_abs_path(&self.root, path);
@@ -263,14 +262,14 @@ impl AzblobCore {
         // Set SSE headers.
         req = self.insert_sse_headers(req);
 
-        if let Some(cache_control) = cache_control {
+        if let Some(cache_control) = args.cache_control() {
             req = req.header(constants::X_MS_BLOB_CACHE_CONTROL, 
cache_control);
         }
         if let Some(size) = size {
             req = req.header(CONTENT_LENGTH, size)
         }
 
-        if let Some(ty) = content_type {
+        if let Some(ty) = args.content_type() {
             req = req.header(CONTENT_TYPE, ty)
         }
 
@@ -305,8 +304,7 @@ impl AzblobCore {
     pub fn azblob_init_appendable_blob_request(
         &self,
         path: &str,
-        content_type: Option<&str>,
-        cache_control: Option<&str>,
+        args: &OpWrite,
     ) -> Result<Request<AsyncBody>> {
         let p = build_abs_path(&self.root, path);
 
@@ -330,11 +328,11 @@ impl AzblobCore {
             "AppendBlob",
         );
 
-        if let Some(ty) = content_type {
+        if let Some(ty) = args.content_type() {
             req = req.header(CONTENT_TYPE, ty)
         }
 
-        if let Some(cache_control) = cache_control {
+        if let Some(cache_control) = args.cache_control() {
             req = req.header(constants::X_MS_BLOB_CACHE_CONTROL, 
cache_control);
         }
 
diff --git a/core/src/services/azblob/writer.rs 
b/core/src/services/azblob/writer.rs
index 301c9f733..bfcde2007 100644
--- a/core/src/services/azblob/writer.rs
+++ b/core/src/services/azblob/writer.rs
@@ -50,8 +50,7 @@ impl oio::OneShotWrite for AzblobWriter {
         let mut req = self.core.azblob_put_blob_request(
             &self.path,
             Some(bs.len() as u64),
-            self.op.content_type(),
-            self.op.cache_control(),
+            &self.op,
             AsyncBody::ChunkedBytes(bs),
         )?;
 
@@ -95,11 +94,9 @@ impl oio::AppendObjectWrite for AzblobWriter {
                 Ok(parse_content_length(headers)?.unwrap_or_default())
             }
             StatusCode::NOT_FOUND => {
-                let mut req = self.core.azblob_init_appendable_blob_request(
-                    &self.path,
-                    self.op.content_type(),
-                    self.op.cache_control(),
-                )?;
+                let mut req = self
+                    .core
+                    .azblob_init_appendable_blob_request(&self.path, 
&self.op)?;
 
                 self.core.sign(&mut req).await?;
 

Reply via email to