diff --git a/core/src/services/azblob/backend.rs b/core/src/services/azblob/backend.rs index 5daa104ede8b..dfd7ca189141 100644 --- a/core/src/services/azblob/backend.rs +++ b/core/src/services/azblob/backend.rs @@ -482,7 +482,10 @@ impl Accessor for AzblobBackend { } async fn read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::Reader)> { - let resp = self.core.azblob_get_blob(path, args.range()).await?; + let resp = self + .core + .azblob_get_blob(path, args.range(), args.if_none_match()) + .await?; let status = resp.status(); @@ -524,13 +527,16 @@ impl Accessor for AzblobBackend { } } - async fn stat(&self, path: &str, _: OpStat) -> Result { + async fn stat(&self, path: &str, args: OpStat) -> Result { // Stat root always returns a DIR. if path == "/" { return Ok(RpStat::new(Metadata::new(EntryMode::DIR))); } - let resp = self.core.azblob_get_blob_properties(path).await?; + let resp = self + .core + .azblob_get_blob_properties(path, args.if_none_match()) + .await?; let status = resp.status(); diff --git a/core/src/services/azblob/core.rs b/core/src/services/azblob/core.rs index 78aac2860ef9..74a2e8d36793 100644 --- a/core/src/services/azblob/core.rs +++ b/core/src/services/azblob/core.rs @@ -24,6 +24,7 @@ use std::str::FromStr; use http::header::HeaderName; use http::header::CONTENT_LENGTH; use http::header::CONTENT_TYPE; +use http::header::IF_NONE_MATCH; use http::Request; use http::Response; use http::Uri; @@ -100,6 +101,7 @@ impl AzblobCore { &self, path: &str, range: BytesRange, + if_none_match: Option<&str>, ) -> Result> { let p = build_abs_path(&self.root, path); @@ -126,6 +128,10 @@ impl AzblobCore { 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)?; @@ -172,6 +178,7 @@ impl AzblobCore { pub async fn azblob_get_blob_properties( &self, path: &str, + if_none_match: Option<&str>, ) -> Result> { let p = build_abs_path(&self.root, path); @@ -182,7 +189,11 @@ impl AzblobCore { percent_encode_path(&p) ); - let req = Request::head(&url); + let mut req = Request::head(&url); + + 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)