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 fdc8d8d2 feat: add if_none_match support for obs (#2103)
fdc8d8d2 is described below

commit fdc8d8d2aea5d725a677244fae2b1a69075f9b25
Author: Jun Zhang <[email protected]>
AuthorDate: Mon Apr 24 19:18:55 2023 +0800

    feat: add if_none_match support for obs (#2103)
    
    This fixes: https://github.com/apache/incubator-opendal/issues/1976
    
    Signed-off-by: Jun Zhang <[email protected]>
---
 core/src/services/obs/backend.rs |  7 +++++--
 core/src/services/obs/core.rs    | 11 +++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/core/src/services/obs/backend.rs b/core/src/services/obs/backend.rs
index a4c924b7..3ed1c55a 100644
--- a/core/src/services/obs/backend.rs
+++ b/core/src/services/obs/backend.rs
@@ -341,7 +341,7 @@ impl Accessor for ObsBackend {
     async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, 
Self::Reader)> {
         let resp = self
             .core
-            .obs_get_object(path, args.range(), args.if_match())
+            .obs_get_object(path, args.range(), args.if_match(), 
args.if_none_match())
             .await?;
 
         let status = resp.status();
@@ -389,7 +389,10 @@ impl Accessor for ObsBackend {
             return Ok(RpStat::new(Metadata::new(EntryMode::DIR)));
         }
 
-        let resp = self.core.obs_get_head_object(path, args.if_match()).await?;
+        let resp = self
+            .core
+            .obs_get_head_object(path, args.if_match(), args.if_none_match())
+            .await?;
 
         let status = resp.status();
 
diff --git a/core/src/services/obs/core.rs b/core/src/services/obs/core.rs
index 1d4e3161..2dab3a8b 100644
--- a/core/src/services/obs/core.rs
+++ b/core/src/services/obs/core.rs
@@ -22,6 +22,7 @@ use http::header::CACHE_CONTROL;
 use http::header::CONTENT_LENGTH;
 use http::header::CONTENT_TYPE;
 use http::header::IF_MATCH;
+use http::header::IF_NONE_MATCH;
 use http::Request;
 use http::Response;
 use reqsign::HuaweicloudObsCredential;
@@ -88,6 +89,7 @@ impl ObsCore {
         path: &str,
         range: BytesRange,
         if_match: Option<&str>,
+        if_none_match: Option<&str>,
     ) -> Result<Response<IncomingAsyncBody>> {
         let p = build_abs_path(&self.root, path);
 
@@ -103,6 +105,10 @@ impl ObsCore {
             req = req.header(http::header::RANGE, range.to_header())
         }
 
+        if let Some(if_none_match) = if_none_match {
+            req = req.header(IF_NONE_MATCH, if_none_match);
+        }
+
         let mut req = req
             .body(AsyncBody::Empty)
             .map_err(new_request_build_error)?;
@@ -146,6 +152,7 @@ impl ObsCore {
         &self,
         path: &str,
         if_match: Option<&str>,
+        if_none_match: Option<&str>,
     ) -> Result<Response<IncomingAsyncBody>> {
         let p = build_abs_path(&self.root, path);
 
@@ -160,6 +167,10 @@ impl ObsCore {
             req = req.header(IF_MATCH, if_match);
         }
 
+        if let Some(if_none_match) = if_none_match {
+            req = req.header(IF_NONE_MATCH, if_none_match);
+        }
+
         let mut req = req
             .body(AsyncBody::Empty)
             .map_err(new_request_build_error)?;

Reply via email to